Order for your organisation.
Learn how to place education orders with Little Bird.
Delving into the world of Arduino can be both exhilarating and intimidating. But, as with any journey, the best way to start is with a single step. In the Arduino universe, that step is often the blinking of an LED. Considered the "Hello World" of electronics, this simple project will introduce you to the basics of Arduino programming and hardware interfacing.
Before we jump into the project, it's essential to familiarize yourself with the Arduino board:
Microcontroller: The brain of the Arduino, often an ATmega series chip. This is where your code resides and runs.
Digital I/O Pins: These pins can be programmed as inputs or outputs. They're where you'll connect devices like LEDs, switches, sensors, and more.
Analog Input Pins: Used primarily to read analog signals, like those from a potentiometer or certain sensors.
Power Pins: Include 3.3V, 5V, GND (ground), and Vin (input voltage). These pins supply power to your connected components.
Reset Button: Resets the microcontroller, effectively restarting your code from the beginning.
TX/RX LEDs: Indicators that light up when data is transmitting (TX) or receiving (RX) via the USB connection.
USB Connector: Allows you to connect the Arduino to your computer, both to upload code and to power the board.
Components Required:
Steps:
Setting up the Circuit:
a. Connect the long leg (anode) of the LED to one end of the resistor.
b. Connect the other end of the resistor to Digital Pin 13 on the Arduino board.
c. Connect the short leg (cathode) of the LED directly to a GND pin on the Arduino.
Programming the Arduino:
a. Launch the Arduino IDE on your computer.
b. Go to File > Examples > Basics > Blink to open the Blink example sketch.
c. Upload the sketch to your Arduino board using the 'Upload' button.
Upon successful upload, the LED should start blinking!
Now, let's break down the essential parts of the Blink sketch:
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
pinMode(): This function sets a pin as either INPUT or OUTPUT. For the Blink sketch, we set the LED_BUILTIN
pin (which is usually Pin 13 on most Arduino boards) as an OUTPUT.
digitalWrite(): This function sets a digital pin to either HIGH or LOW. In the context of our LED, setting the pin to HIGH sends voltage to light it up, and setting it to LOW turns it off.
delay(): Pauses the program for the specified amount of time, in milliseconds. This function gives us the blink effect by turning the LED on and off at 1-second intervals.
Conclusion
Congratulations! By successfully completing this project, you've taken your first steps into the vast world of Arduino. You've learned to set up a simple circuit and understand the basics of an Arduino sketch. From here, the possibilities are endless, and with each new project, you'll expand your knowledge and skills. Happy tinkering!
Leave a comment