Activity1 2 3 LEDs
Activity1 2 3 LEDs
START
TURN ON
LED
DELAY
TURN OFF
LED
DELAY
ACTIVITY 2: ALTERNATE BLINKING Objectives:
Description: • Connecting and controlling an LED
attached to an Arduino's digital outputs.
The blinking LED circuit is related to the
• Blinking lights are designed to disrupt
electrical version of the "Hello World" software.
the flow of electricity at regular intervals,
To start, we will focus on flashing an LED, which
causing the light to flash on and off
serves as the microcontroller's Hello World. It's
indefinitely.
as simple as turning on and off a light switch with
2 LEDs. Coding:
Components and Supplies: int REDPIN=13;
1 × Breadboard int YELLOWPIN=12;
1 × Arduino Uno R3
2 × LED void setup() {
2 × 220Ω Resistor //Set the pins to output pins using pinMode
3 × Jumper pinMode(REDPIN,OUTPUT);
Flow Chart: pinMode(YELLOWPIN,OUTPUT);
}
START void loop() {
//Make the LEDs blink in turn:
// Turn on the red led, and turn off the yello and
DELAY green leds.
TURN ON
RED LED
digitalWrite(REDPIN,HIGH);
TURN OFF
DELAY YELLOW LED digitalWrite(YELLOWPIN,LOW);
delay(100);
TURN ON
DELAY YELLOW LED digitalWrite(REDPIN,LOW);
digitalWrite(YELLOWPIN,HIGH);
delay(100);
}
Schematic Diagram: Flow Chart:
START
TURN ON
TURN ON DELAY
GREEN LED
RED LED
TURN OFF
TURN OFF DELAY GREEN LED
ACTIVITY 3: TRAFFIC LIGHTS RED LED
Description:
The blinking LED circuit is related to the TURN ON
electrical version of the "Hello World" software. DELAY YELLOW LED
To start, we will focus on flashing an LED, which
serves as the microcontroller's Hello World. It's
as simple as turning on and off a light switch with
2 LEDs.
Coding:
Components and Supplies:
int REDPIN=13;
1 × Breadboard
int YELLOWPIN=12;
1 × Arduino Uno R3
int GREENPIN=11;
3 × LED
3 × 220Ω Resistor
void setup() {
4 × Jumper
//Set the pins to output pins using pinMode
pinMode(REDPIN,OUTPUT);
pinMode(YELLOWPIN,OUTPUT);
pinMode(GREENPIN,OUTPUT);
}
void loop() {
//Make the LEDs blink in turn:
// Turn on the red led, and turn off the yello and Schematic Diagram:
green leds.
digitalWrite(REDPIN,HIGH);
digitalWrite(YELLOWPIN,LOW);
digitalWrite(GREENPIN,LOW);
delay(500);
//Turn in the yellow led, and turn off the red and
green leds.
digitalWrite(REDPIN,LOW);
digitalWrite(YELLOWPIN,HIGH); Analyzation:
digitalWrite(GREENPIN,LOW); • When the jumper wire is not properly
delay(500); inserted, the LEDs will not begin
automatically blink.
• If there is an error in the code you enter
//Turn on the green led, and turn off the red and into the Arduino, it will not operate.
yellow leds. Conclusion: