Project Basics
The Make a Simple LED Flash project is the official "Hello, World!" for the Arduino platform. It focuses on the fundamental link between hardware and software, teaching how a line of code can physically manifest as a blinking light.
Hardware Circuit
The circuit is intentionally kept small and easy to understand:
- LED Anode: Connected to a Digital Pin (usually Pin 13).
- LED Cathode: Connected to the Arduino's Ground (GND) pin.
- Resistor: A 220-ohm resistor is placed in series with the LED to limit the current, preventing damage to the LED and the Arduino pin.
Logic Flow: HIGH and LOW
The Arduino is programmed with two states:
HIGH: Sends 5V to the pin, lighting the LED.LOW: Sends 0V to the pin, turning the LED off.
By combining these states with the delay() function, we create the recognizable blinking effect:
void loop() {
digitalWrite(13, HIGH);
delay(1000); // 1-second delay
digitalWrite(13, LOW);
delay(1000);
}
Key Learnings
void setup(): Used to tell the Arduino that Pin 13 is anOUTPUT.void loop(): Used to contain the logic that will run continuously until power is removed.- Timing: By decreasing the delay values, you can make the LED flash very rapidly or very slowly.
Next Steps
Once you have the LED flashing, you can try:
- Adding More LEDs: Connect more LEDs to different pins and make them blink in different patterns.
- Using PWM: Use the
analogWrite()command on PWM pins to make the LED smoothly fade in and out instead of flashing. - Adding a Sensor: Use a button or a light sensor to trigger the blinking.
This simple project is the first step toward building more complex gadgets and robots.