filmov
tv
How to Make Arduino Traffic Light from Cardboard
Показать описание
In this video, you will learn how to Make an Arduino Traffic Light for Science Project
Materials Used:
1) 2 RED LED, 2 GREEN LED, 1 YELLOW LED
2) 6, 330 OHM resistors
3) Arduino UNO
4) Flats/Jumper Wires
5) Breadboard
6) Cardboard/Sticks
SKETCH: const int ledRed = 13;
const int ledGreen = 12;
const int ledyellow = 11;
const int buttonPin = 10;
const int ledpedRed = 9;
const int ledpedGreen = 8;
int buttonState = 0;
void setup() {
pinMode(ledRed, OUTPUT);
pinMode(ledGreen, OUTPUT);
pinMode(ledyellow, OUTPUT);
pinMode(ledpedRed, OUTPUT);
pinMode(ledpedGreen, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if(buttonState == HIGH){
digitalWrite(ledpedRed, LOW);
digitalWrite(ledGreen, LOW);
digitalWrite(ledpedGreen, HIGH);
digitalWrite(ledyellow, HIGH);
digitalWrite(ledRed, HIGH);
delay(1000);
digitalWrite(ledGreen, HIGH);
digitalWrite(ledyellow, LOW);
delay(1000);
digitalWrite(ledyellow, HIGH);
digitalWrite(ledRed, LOW);
delay(1000);
digitalWrite(ledpedRed, HIGH);
digitalWrite(ledRed, LOW);
delay(1000);
digitalWrite(ledpedGreen, LOW);
delay(5000);
digitalWrite(ledpedGreen, HIGH);
digitalWrite(ledGreen, LOW);
digitalWrite(ledRed, HIGH);
digitalWrite(ledpedRed, LOW);
delay(1000);
}else{
}
}
These digital pins also include GND and +5V to power the Arduino
MUSIC:
).
.
).
.
).
.
Materials Used:
1) 2 RED LED, 2 GREEN LED, 1 YELLOW LED
2) 6, 330 OHM resistors
3) Arduino UNO
4) Flats/Jumper Wires
5) Breadboard
6) Cardboard/Sticks
SKETCH: const int ledRed = 13;
const int ledGreen = 12;
const int ledyellow = 11;
const int buttonPin = 10;
const int ledpedRed = 9;
const int ledpedGreen = 8;
int buttonState = 0;
void setup() {
pinMode(ledRed, OUTPUT);
pinMode(ledGreen, OUTPUT);
pinMode(ledyellow, OUTPUT);
pinMode(ledpedRed, OUTPUT);
pinMode(ledpedGreen, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if(buttonState == HIGH){
digitalWrite(ledpedRed, LOW);
digitalWrite(ledGreen, LOW);
digitalWrite(ledpedGreen, HIGH);
digitalWrite(ledyellow, HIGH);
digitalWrite(ledRed, HIGH);
delay(1000);
digitalWrite(ledGreen, HIGH);
digitalWrite(ledyellow, LOW);
delay(1000);
digitalWrite(ledyellow, HIGH);
digitalWrite(ledRed, LOW);
delay(1000);
digitalWrite(ledpedRed, HIGH);
digitalWrite(ledRed, LOW);
delay(1000);
digitalWrite(ledpedGreen, LOW);
delay(5000);
digitalWrite(ledpedGreen, HIGH);
digitalWrite(ledGreen, LOW);
digitalWrite(ledRed, HIGH);
digitalWrite(ledpedRed, LOW);
delay(1000);
}else{
}
}
These digital pins also include GND and +5V to power the Arduino
MUSIC:
).
.
).
.
).
.
Комментарии