Final answer:
To blink three different-colored LEDs with Arduino, wire each to a separate digital pin through a resistor, and write a code to control the on-off timing for each LED. The red LED is on for one second, green for two, and yellow for three seconds, ensuring no overlap when all are either off or on. Upload the code to the Arduino to execute the blinking pattern.
Step-by-step explanation:
Building an Arduino Blinking LEDs Circuit
To build a circuit that blinks three LEDs (red, green and yellow) with an Arduino, follow these steps:
- Connect the long leg of the red LED to the digital pin 2 on the Arduino.
- Connect the long leg of the green LED to digital pin 3.
- Connect the long leg of the yellow LED to digital pin 4.
- Connect the short legs of the LEDs to the ground (GND) through a 220-ohm resistor each to limit the current.
The Arduino code to achieve the alternating blinking is as follows:
void setup() {
pinMode(2, OUTPUT); // Red
pinMode(3, OUTPUT); // Green
pinMode(4, OUTPUT); // Yellow
}
void loop() {
digitalWrite(2, HIGH); // Turn on Red LED
delay(1000); // Wait for 1 second
digitalWrite(2, LOW); // Turn off Red LED
digitalWrite(3, HIGH); // Turn on Green LED
delay(2000); // Wait for 2 seconds
digitalWrite(3, LOW); // Turn off Green LED
digitalWrite(4, HIGH); // Turn on Yellow LED
delay(3000); // Wait for 3 seconds
digitalWrite(4, LOW); // Turn off Yellow LED
}
Remember to upload the Arduino sketch (.ino file) to your board using the Arduino IDE. Simulation files are usually not necessary unless specified in a classroom setting or when using a specific software for emulating the circuit.
Each LED is turned on for its specified duration and then turned off before the next one is turned on, ensuring that not all LEDs are off or on at the same time.