Introduction: Project 1, Blinking LED
Welcome to my series, Arduino Basics. In this first lesson you will learn how to make a LED blink. This is a very easy project and great for beginners who want to learn what Arduino is as how to use it. I encourage anyone who does this project to read through the notes and fully understand what each function and line of code does before moving on. I hope you enjoy this project and the ones to come.
Hardware Required:
- 1 Arduino Uno
- 1 Solderless breadboard
- 1 220 ohm resistor
- 1 Jumper wire
- 1 LED diode
Software Required:
- Arduino IDE
Step 1: The Hardware
Build your circuit like the picture above. Make sure that your LED diode is positioned right, with the long wire(Positive) is connected to digital pin9.
Step 2: The Code
Type the code below into your Arduino IDE window. If you have not downloaded it yet there is a link to the download page at the bottom of the page. make sure that you type it in exactly the same. Commands(functions) are "case sensitive".
void setup(){
pinMode(9, OUTPUT); // This tells the Arduino board that pin 9 is an OUTPUT pin.
}
void loop(){
digitalWrite(9, HIGH); //Tells the Arduino to put 5 volts of power through pin 9
delay(250); //Wait 250 milliseconds
digitalWrite(9, LOW); //Tells the Arduino to put 0 volts of power through pin 9
delay(250); //Wait 250 milliseconds
Step 3: Upload to the Board
Now that the hardware is built and the code is written you must upload it to the board. In order to do this go to the top left corner of the Arduino IDE. First click the verify button. it is circular and has a check mark on it. If the code is written correctly there will be a message that says, "done compiling". Once that is ready you can upload.
Go to the very top of the window and select Tools>port, then you need to select the port that your Arduino is connected to. If multiple ports show up try to disconnect other USB devices. You will also need to select the type of board you are using, in this case and Arduino UNO. Go to Tools>Board and select Arduino/Genuino Uno.
Once all of that is done, click the upload button. It is located beside the verify one and has a picture of a sideways arrow on it. If problems occur check out the Arduino support page, link is at the bottom of page.
Step 4: Conclusion
Good job on completing project 1. You learned about pinMode, digitalWrite, HIGH and LOW, OUTPUT, and delay. Now I challenge you. Try to make your LED blink at different speeds. You can also switch your LED out for a buzzer(piezo speaker). have fun with it and use your imagination.