Arduino 001: Arduino Startup

This will help you:

Download Arduino software and start using your Arduino

Arduino is a very useful platform that allows you to control electronic circuits and devices with code. The language used is based on C/C++, but you don't need to know much to get started. Arduino has a lot of online documentation, resources and tutorials provided by the creators and the user community, so it's very friendly to beginners. Having a background knowledge of how programs work (variables, loops, conditionals, functions) is helpful, but you can quickly get up to speed.

In this activity, you'll download and install the Arduino IDE (integrated development environment), which helps you write and debug programs and upload them to your Arduino. You'll build a very basic circuit and run a demo script which blinks an LED.

Time: .5-1 hours / Level: A1

You should already:

  • Have the supplies listed below

You Will Need:

  • A computer (with internet access for installing Arduino software)

  • an Arduino (most of these activities are based on an Arduino Uno rev. 3)

  • a USB 2.0 A-to-B cable

Step 1: Download the Arduino IDE

Go to the Arduino software page, scroll down to "Download the Arduino IDE", and click on the link for your system (if you're using Windows, the Windows installer is probably what you want.) Follow the prompts to download and install the program.

To open the Arduino IDE, you can either find arduino.exe in the folder where it downloaded and double-click it, or you can search for "arduino" in your Programs/Start menu.

Step 2: Connect Your Arduino

Here is the guide for connecting an Arduino Uno and using the IDE with it. It has more detailed instructions with images, but I'll provide an overview here.

Connect your Arduino to a USB port on your computer using the A-to-B cable. Open the IDE and go to "Tools->Board" and select the board type you are using. Then, go to "Tools->Port" and select one of the ports ("COM##") that lists the name of your board next to it.

Step 3: Load a Program

In the IDE, open "File->Examples->01.Basics->Blink". This is an example sketch (Arduino script) that blinks the built-in LED on the board.

Read the program and if you want, check out the official tuorial. There are 3 main parts: the header comment, which explains who wrote the program and what it does, the setup() function, which runs once at the beginning of the program, and the loop() function, which runs repeatedly after the setup() function.

pinMode(pin, mode) is a function required when using one of the board's GPIO (general-purpose input/output) pins. It just declares that the pin number provided will be used for a certain purpose. Pins can't be used for input and output at the same time. LED_BUILTIN is a predefined value in Arduino programs which has the value of the pin number connected to the built in LED.

digitalWrite(pin, value) is a function which writes (sends/outputs) a value to a digital pin with the number provided. Since it's a digital pin, the only options are HIGH or LOW. Once you call digitalWrite(pin, HIGH), the voltage on pin will be whatever the HIGH voltage is, probably around 5V. When you call digitalWrite(pin, LOW), the voltage on pin will be close to 0V. Since the pin LED_BUILTIN is connected to the built-in LED, setting that voltage will cause the LED to turn on and off.

delay(ms) just causes the program to delay for the given number of milliseconds (1/1000th of a second). Putting it after each digitalWrite() will cause the LED to stay how it is for 1000 milliseconds (1 second) in this example.

Step 4: Upload the Program

Arduino code runs on the Arduino hardware, not on your computer. If you write a program that blinks an LED, your computer does not tell the LED to blink. Your computer checks that your code looks kind of okay, and sends it to the Arduino via the USB connection. The Arduino then runs that code as long as it is powered on. The Arduino is getting power from your computer by default when it's plugged in via the USB, but you could disconnect it and connect another power source, and it would run whatever code had last been uploaded.

After you write a program, you should click the check mark in the upper left corner ("Verify") to check that your code kind of makes sense. If there are any obvious problems with what you've written, the IDE will tell you. Then, you can click the arrow next to Verify ("Upload") to program the Arduino.

If this fails, you should check that the Arduino's connection to the computer is good, and that the correct port is selected in "Tools->Port". If none of the port options show the name of your board, the board may not be connected properly or the driver may not have installed correctly (see here for driver install instructions.) Once you resolve your connection issue, try uploading again.

Try opening, verifying, and uploading the Blink example script. If that works, change the values of delay() and add more digitalWrite() commands to create your own blinking pattern. You will have to re-upload each time for the changes to take effect.