Blinking an LED
In this tutorial, we will take the first step into the exciting world of Arduino by creating a simple project to blink an LED. This project is perfect for beginners and will teach you the basics of setting up your Arduino board, writing code, and controlling hardware components. By the end of this tutorial, you'll have a blinking LED that you can control with your Arduino board
Step 1
Setting Up the Hardware:
Place your Arduino board and breadboard on a flat surface.
You can find out more about the Arduino board here
Step 2
Inserting the LED (Light Emitting Diode):
Insert the LED into the breadboard
LEDs have a longer leg (anode) and a shorter leg (cathode).
You can learn more about LEDS here
Connect the longer leg (anode) of the LED into the breadboard at C1 like shown in the picture
Connect the shorter leg (cathode) of the LED into the breadboard at C4 like shown in the picture
Step 3
Connecting the Resistor:
Insert the (330 Ohm) Resistor into the breadboard
A resistor is a passive two-terminal electronic component that is used to restrict or limit the flow of electric current in a circuit.
What do those funny colors mean ?
Resistor Color Code
An electronic color code is a code that is used to specify the ratings of certain electrical components, such as the resistance in Ohms of a resistor
This resistor has (Orange-Orange-Brown) as its color code. You can learn more about resistors by following this link
Insert the (330 Ohm) Resistor into the breadboard
Put one end into E 1 and the other into F 1 as shown in the picutre.
Step 4
Connecting the the Arduino:
Insert a jumper cable (red cable) into L 1
Insert the other side of the jumper cable into PIN 13 on the Arduino board.
Step 6
Connecting Ground to Circuit
Connect the jumper cable into E 3 as shown in the example (black cable)
Connect the other end of the cable into the Arduino PIN GND for Ground
Step 7
Connect the USB to the Arduino
Connect the USB cable into the Arduino
Open up the Arduino IDE ( you can download it here)
Step 8
Open up the Arduino IDE and connect the Uno Board
Now, you need to select the right core & board. This is done by navigating to Tools > Board > Arduino AVR Boards > Board. Make sure you select the board that you are using.
Step 9
Making sure the Arduino board select is connect to correct COM port
Now, let's make sure that your board is found by the computer, by selecting the port. This is simply done by navigating to Tools > Port, where you select your board from the list.
Step 10
Running the BLINK example
Let’s try an example: navigate to File > Examples > 01.Basics > Blink.
To upload it to your board, simply click on the arrow in the top left corner. This process takes a few seconds, and it is important to not disconnect the board during this process. If the upload is successful, the message "Done uploading" will appear in the bottom output area.
Once the upload is complete, you should then see on your board the with your LED start blink. You can adjust the speed of blinking by changing the delay number in the parenthesis to 100, and upload the Blink sketch again. Now the LED should blink much faster.
Congratulations! You have successfully programmed your board to blink an LED!
Arduino code below with detailed comments explaining each part to someone who's new to programming
// The Arduino code is organized into two main functions: "setup" and "loop."
void setup() {
// In the "setup" function, we initialize things.// This line tells the Arduino that we want to use Pin 13 as an output.
pinMode(13, OUTPUT); // Set Pin 13 as an output}
void loop() {
// The "loop" function contains the main code that runs continuously. // This line turns Pin 13 (connected to the LED) on by providing power to it.
digitalWrite(13, HIGH); // Turn the LED on
// The following line pauses the code for 1,000 milliseconds, which is 1 second.
delay(1000); // Wait for 1 second
// After the delay, we turn off Pin 13 to turn off the LED.
digitalWrite(13, LOW); // Turn the LED off
// Another 1-second delay before repeating the loop.
delay(1000); // Wait for 1 second}
Now, let's go through each part:
// This is a comment...: This is a comment that explains what's happening in the code. Comments are ignored by the Arduino and are only for human understanding.
void setup() { ... }: This is the "setup" function. It's run once when the Arduino starts. In the setup function, we configure settings and set things up.
pinMode(13, OUTPUT);: This line tells the Arduino that we want to use Pin 13 as an output. In other words, we want to send electrical signals from Pin 13.
void loop() { ... }: The "loop" function contains the main part of your code. It runs repeatedly, over and over.
digitalWrite(13, HIGH);: This line turns on Pin 13 by providing a high electrical voltage. This causes the LED to light up.
delay(1000);: Here, we insert a pause in the code for 1,000 milliseconds (1 second). The Arduino does nothing during this time, so the LED remains on.
digitalWrite(13, LOW);: This line turns off Pin 13 by providing a low electrical voltage. The LED goes off.
delay(1000);: Another 1-second delay before the loop repeats.
By following these instructions, the Arduino repeatedly turns the LED on for one second and then turns it off for one second, creating the blinking effect
Donate
If you've enjoyed exploring my Arduino projects and want to see more amazing creations, your support can make a big difference! By contributing, you're helping me continue to innovate and bring even more exciting projects to life. Together, we can explore the endless possibilities of DIY electronics! Don't forget to like, subscribe, and follow for updates on the latest developments. Thank you for being a part of this journey!
Click here to make a difference with your donation today!