DEV Community

Kim Arnett 
Kim Arnett 

Posted on

Blinky - Hello World of Robotics

Hey ya'll! I hope you enjoyed my first robotics post and are ready to start your own! Orig post over at my blog

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:

1        2        3        4        5

header

  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

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;
Enter fullscreen mode Exit fullscreen mode

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

pinMode(led, OUTPUT);
Enter fullscreen mode Exit fullscreen mode

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);
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (7)

Collapse
 
charlyn profile image
Charlyn Gonda

This is awesome! Haven’t tried the Arduino Uno yet, I think now I can! 💖

Collapse
 
ben profile image
Ben Halpern

I'm going to break out my Arduino and try to keep up with you 😄

Collapse
 
kaydacode profile image
Kim Arnett 

Yaaas! Dust it off, lets do this :D I need a reason to continue on my robotics journey. The interest is fading and heading over to AI. lol. Short attention span apparently.

Collapse
 
kayis profile image
K

What's the next step?
In app development I do a todo list and a blog next.

Collapse
 
kaydacode profile image
Kim Arnett 

I was hoping to have more time to do robotics projects & blogs, but unfortunately I don't. The next step would be to build something :D

I bought this book which contains a few projects complete with code and what you need - I felt it was lacking in some areas, so if you're willing to spend some time on google filling in the missing pieces.. it's do able. I'm still planning to work my way through it, I only did the Roomba project, but it's going to take a while.

Otherwise there's some tutorials online - sparkfun.com has many good things on their for the Arduino, including tutorials and decently priced parts.

Collapse
 
jess profile image
Jess Lee

Whoo! Thanks for the instructions :)
I did my first (and only) hardware thing earlier this month at Google I/O. Have you heard of their codelabs?

Collapse
 
kaydacode profile image
Kim Arnett 

Nope, I'm pretty separated from all things Google. Not on purpose, but just so into iOS lately. lol. What's it all about?