Blinky – Hello World of Robots

Hey ya’ll! I hope you enjoyed my first robotics post and are ready to start your own!

This is an introduction to your Arduino Uno. I am still new to robotics myself, but together we will prevail. I hope to pass on what I know and you can pass on what you know, and soon we’ll all be experts, right?!

Whenever you’re learning a new software platform, you create a “Hello World” application. Well, the equivalent in the hardware world is called “Blinky”. This tutorial is an introduction to the Arduino platform. I’ll be using the Arduino Uno R3 and an LED bulb that came with my learn to solder kit.

 

Download the Arduino IDE

here: arduino.cc/en/Main/Software
*This tutorial is using Arduino 1.8.1

As a beginner, I had better luck using on Windows 10 platform than I did my 2015 MacBook Pro. I ran into a driver problem on the Mac and possibly downloaded a Japanese virus while trying to fix it. Oops.

Quick IDE Intro:

*Hover over images for tooltips*

1. Verify – Compile the code to see if there are any right out failures or errors.
2. Upload – Put the code on the Arduino. Code will begin running right away as long as there’s power.
3. New – Create a new document
4. Open – Open an existing document
5. Save – Save the document to your computer

Prep the Uno

1. Plug it into your USB slot

2. The board will light up indicating there’s power

3. Find an LED – Put the positive end (Longest leg / smallest piece inside the LED) into pin 13. Insert the negative end into the GND (Ground) pin.

4. Should look something like

![setup](https://i1.wp.com/www.kimarnett.com/blog/wp-content/uploads/2017/05/IMG_7491.jpg)

Code

When you create a new file, or the default one, you’ll see two methods: Setup and Loop.Setup is run exactly one time at the beginning of the program by the hardware, than the continuous code goes in the, you guessed it, loop function.At the beginning of the file we’ll make a reference to the pin our LED is in:

int led = 13;

In the setup function we’ll define the LED as an output with:

pinMode(led, OUTPUT);

Lastly in the loop function, we’ll tell the light to blink. We send a signal to the pin (13), which will be either HIGH or LOW. This signal corresponds to the voltage given to that pin. HIGH, the light will turn on, and LOW the light will turn off. We also want to delay, wait, between turning the light on and off. Here’s the code for the loop function:

digitalWrite(led, HIGH);
delay(5000);
digitalWrite(led, LOW);
delay(1000);

Save -> Verify -> Upload

Press the Verify button at the top (Checkmark). This will sweep through your code and make sure no outstanding issues exist.

Note: If you get this error on Windows (ser_open(): can’t open device “\\.\COM[x]”)
Open Device Manager → Ports → and determine what port the Uno is on. Then Go to Tools → Port → then select the correct port it’s expecting.

If everything comes out good, select the upload button.

Once the program compiles the Uno will refresh and your program should now be running. The light will be on for 5 seconds, and off for 1 second.

 

Code On Github     |     Original tutorial here.

That Time I Built a Robot<< >>How to Level Up Your Dev Game

About the author : Kim

Kim Arnett is an iOS Developer at DXC Technology. She enjoys watching her creations work wonders while making a positive impact on the population. She’s interested in technology, feminism, mental health, and Iron Man. Current side project includes learning robotics.