Skip to content

Instantly share code, notes, and snippets.

@topshed
Last active May 24, 2018 16:45
Show Gist options
  • Save topshed/0622cf42318df80568d0a369c4ac9988 to your computer and use it in GitHub Desktop.
Save topshed/0622cf42318df80568d0a369c4ac9988 to your computer and use it in GitHub Desktop.

Introduction to Arduino

Types of Arduino

Just like Raspberry Pi, Arduino both the open of a computer company and their project: a single-board microcontrollers and microcontroller for building digital devices and interactive objects that can sense and control objects in the physical and digital world. The project's products are distributed as open-source hardware and software, which are licensed under licenses that allow anyone to manufacture of Arduino boards.

There are lots of dirrent types of Arduino. Many are based around the ATMega328 chip, although there are now lots of other varieties in use.

Official Arduino/Genuino models come in a range of sizes. from left to right: Leonardo, Uno, MKR Zero and Micro.

Imgur

The most common Arduino model, and one often used for prototyping is the Uno. There have been several different versions of the Uno, the latest being Rev. 3 (right below). You can see that the older versions have a much larger Intergrated Circuit (chip) - this is the ATMega328.

Imgur

The Rev .3 also has the ports labels on the side to make wiring up circuits even easier. However, you can use the smaller Arduinos, like the Micro in exactly the same way. You just need to ensure that you look up the pinouts for whichever model you're using (to make sure you're connecting things to the right pins) and select the right board when uploading code from the editor.

Arduino is Open-source hardware and shares much of the principles and approach of free and open-source software. In particular, they believe that people should be able to study their hardware to understand how it works, make changes to it, and share those changes. Therefore many other companies release Arduino-compatible products. For example, Adafruit make some very small Trinket models 9shown next to an Uno here for camparison).

Imgur

Once again, these can be prgrammed in the same way as the larger models, and code written for an Uno can be compiled to run on a Trinket (although some features such as the Serial Monitor) are not supported.

Just like the Raspberry Pi has HATs, you can also purchase add-on boards for Arduino, called Shields.

Imgur

These have pins that match up with the ports on an the Arduino - most are designed for the Uno but there are also shields for the Leonardo too.

Imgur

The DIY Gamer Kit is an advanced Shield turns an Arduino Uno into a programmable handheld Games Console.

Imgur

Adafruit also make a range of smaller boards called Feather, which often have built-in addaitional hardware and also come with their own range of add-ons (called Wings).

Imgur

The last couple of years has seen some new innovative ways or making Arduino compatible boards designed especially for prototyping. The MonkMakesDuino is one that can be plugged directly into a breadboard:

Imgur

And a similar idea - DevDuino - which also includes built-in buttons, a buzzer, an LCD display and a voltmeter:

Imgur

One clever design - STEMTERA - actually builds the Arduino-clone into the breadboard itself (and is compatible with Lego)

Imgur

Other funky and cool designs have also been produced like this one from Boldport, "The Cuttle":

Imgur)

Other creative uses for Arduino in embedded projects include using one to produce a high-tech festival badge like this one from EMF Camp 2014.

Imgur

And fon't forget, because the Arduino design is open hardware, you can even build your own on a breadboard:

Imgur

The Arduino IDE

Most Arduino boards use serial communications interfaces, including Universal Serial Bus (USB) on some models. The USB is also used for uploading Arduino programs written on computers. The microcontrollers are normally programmed using a subset of features from the programming languages C and C++. To make this easy, the Arduino project provides an integrated development environment (IDE) which can be used to both edit code and handle the upload process. Versions of the Arduino IDE are available for Windows, Mac, Linux (including the Raspberry Pi).

To setup the IDE, you need to tell it which type of Arduino you're using and how it is connected to your computer. To set the type of Arduino, click on Tools then select Board and chhoose your device from the list. If you're using an Arduino compatible board made by another manufacturer (e.g. an Arduino Feather) then you will need to download additional board drivers. Check the manufacturers documentation for how to do this.

Imgur

Next you need to slect the port that your Arduino is connected to. Clcik on Tools and then Port. What to select here will dpened on what computer you're using. If it's a Raspberry Pi or another Linux machine, then it will probably be something like /dev/ttyUSB0. For a Mac, look for something like /dev/usbmodemFD141 (and it may have the board type in brackets). On a Windows machine it will usually be COM3 or something similar.

Imgur

The IDE is simple to use. Type your code in the big white area - normally when you open the program for teh first time or start a new program, the template code will be filled in for you.

Once you've added some of your own code, click on the tick in the circle on the top left of the IDE. This will compile your program. Some other text-based languages, like Python, are interpreted languages. This means that your code is run directly by your computer. The type of C used by Arduino is a compiled language and so the source code that you write must be compiled first to create an executable file.

Imgur

This file is then needs to be uploaded to the Arduino where it will be run. You can do this using the IDE by clicking on the right-arrow button.

Imgur !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment