Getting Started - LEDs
Last updated
Was this helpful?
Last updated
Was this helpful?
First find the logo like this on your computer and open it up.
Now plug in your Arduino like this: Connect the other side to a USB port on your computer.
When you open up the Arduino Integrated Development Environment (IDE for short) you will need to choose Tools → Port and then make sure that you see Arduino Uno (it might not say COM16… your port might be different).
Now delete all the code in your editor and copy/paste the following code into your editor.
Now click the horizontal arrow to upload your code to the Arduino. When prompted to, save your file as “Blink”. TIP: Try to save all your projects with names that will make them easy to find later!
You should now see a little light next to a letter L blinking.
A few notes about the code... there are at least three sections to every Arduino program...
Variables
This is where all the data that will be used throughout the project gets declared. You will also see libraries get added here.
Setup
This code runs once when the board gets power or reset button gets pressed.
Loop
This code repeats over and over without stopping until the board loses power.
6. Now that you have your first program running, let's wire up our own LED! You will need the following pieces…
A resistor
This limits the amount of current flowing through the circuit. Orientation doesn’t matter. The stripes tell you the value of the resistor. Use any piece you can find.
An LED
Only conducts current one way! The long side is positive!
A breadboard
Used to make quick temporary connections while testing circuits and learning.
Red/Blue horizontal rows are connected. Vertical rows in the middle are connected.
Some wires
Conduct electricity. Don’t worry about getting the color right.
Here is the circuit. Don’t worry about exact placement… just make sure you get parts connected to one another in the same row like shown below.
If wired correctly, the same code should be making your LED blink as well.
A few things to try…
Change the value of ledPin to some other number between 3 and 12 and re-upload the code. You should notice the LEDs are not blinking anymore. Now move the red wire to whatever pin number you chose. Notice the LED is blinking again.
Change the speed of the blinking by adjusting the delay time variable. This value is used in the delay function to control how many milliseconds the program waits until a new command is given
Flip the orientation of the LED. Notice that it stops blinking. This proves to you that LEDs only conduct electricity in one direction.
Take a look at this for an explanation of the functions used in the sketch.