
Blinking Light Courtesy of Batsocks
As with many things in life, you must learn to crawl before you can walk. Learning how to actually use an Arduino board is no different therefore we will continue our Arduino Journey by completing a simple project. The first thing a novice should learn is how to control an LED. Light-emitting diodes (LEDs) are small, powerful lights that are used in many different applications such as notification lights in our phones, displays, and in sensors. Designers most often times don’t want their LEDs to always be on or at their full brightness so controlling an LED’s state will be the focus of this project.
The first thing an inventor needs to do is gather all necessary components to build the project. This includes the following:
1 x LED (any color)
1 x 330 ohm resistor
Various jumper wires
Arduino Uno (or similar board)
Protoboard (to place your components)
Arduino Code (I’ll cover this after hooking everything up!)
Most beginner kits will have these basic components already but if you are missing anything your local electronics store should carry it. The setup of the circuit is very straight forward as shown below. NOTE: Be smart with your decisions! We are not responsible for misuse of electronics and injury! Before connecting anything together, it’s safe practice to disconnect the Arduino board from your computer or power source. This essentially cuts power to the board allowing the user to move things around without the risk of shock. Place a jumper wire from the 5V output on the Arduino to the red positive vertical strip on the protoboard. Do the same for ground; running a jumper from GND to the negative strip on the protoboard. The two vertical columns on the side of the protoboard are all connected to together. Anything placed on the vertical positive column will be charged to 5V. Anything placed along the negative ground column will be grounded. Conversely, the middle rows of the protoboard are connected horizontally. Anything placed along the same row will be connected together.

Courtesy of Vilros Starter Kit Guide by Sparkfun
Place a jumper wire from any pin (such as pin 13) to any location in the middle of the protoboard. Now we place our LED. The two legs of our LED are of different lengths. The longer leg should be connected to positive (+) and the shorter leg should be connected to negative (ground). LED’s are diodes which mean that the current is meant to flow from positive to negative, so knowing which leg is which is important. The positive leg of the LED is connected in the same row at the jumper from pin 13. Now that we have placed our LED we can place our resistor. Resistors are components that reduce current flow and act to lower voltage in circuits. It is used in this project to protect our LED by reducing the current flowing through it. One leg is placed in the same row as the negative LED leg and the other is connected to ground completing our circuit. You most likely have to bend the legs of your resistor by 90o to fit into the protoboard. If you are lost, just take a look above at the layout diagram to clear things up!
Now that we have hooked up all of our components, we can move onto the code. For the Arduino code to successfully operate two “functions” are necessary to define. The first is setup() which essentially sets up all the pins we need to work with. We can make our pins operate as inputs or outputs depending on what our project needs. For this specific task all we need to do is set pin 13 (or the pin you’re using) as an output. This is done by saying: pinmode(13,OUTPUT);
The next function is called loop() which runs indefinitely until we unplug our Arduino board. Here we place our desired actions, calculations, and operations. For this project we need to make the LED turn on and then turn off. This is done by saying: digitalWrite(13, HIGH) and digitalWrite(13,LOW). Setting our pin HIGH means supplying the pin with 5V, which turns our LED on. LOW supplies the pin with 0V which turns the LED off. Adding the delay, as shown in the code below, pauses the loop for a given amount of time (measured in milliseconds). Adjusting the delay value will change how long the LED stays on versus the time it stays off. You can simply copy the code below into your code window and it should work. All that’s left to do is connect your Arduino board to the computer, click verify, click upload, and your project will be up and running!
CODE
void setup()
{
pinMode(13,OUTPUT);
}
//this is setting up pin number 13 on the arduino board as the output pin.
//the first value in the parenthesis is a pin and the second value is the function.
//now we move onto the loop which will run forever until the board is unplugged or reset.
void loop()
{
digitalWrite(13, HIGH); // LED on.
//digitalWrite is a function used to make an ouput HIGH or LOW, 5V or 0V.
delay(1000);
//this pauses the loop for a given amount of time measured in milliseconds
digitalWrite(13, LOW); //LED off.
delay(1000);
}
As I said before, adjusting your delay values will result in different blinking rates so go ahead and try it out! Keep a look out for my next tutorial on controlling multiple LED’s.
We appreciate all of your support! Please check out our GoFundMe site to help us complete our senior project. Thanks!