Arduino two way traffic light - Two Way Traffic Light Circuit in Tinker cad

preview_player
Показать описание
Arduino two way traffic light - Two Way Traffic Light Circuit in Tinker cad

SUBSCRIBE AND TURN ALL NOTIFICATIONS ON TO SEE NEW VIDEOS

Two Way Traffic light CODE BELOW:

// Arduino Two Way Traffic Light by Average Education

// Traffic light one
int red1 = 10;
int yellow1 = 9;
int green1 = 8;

// Traffic light two
int red2 = 13;
int yellow2 = 12;
int green2 = 11;

void setup () {
// Traffic light one
pinMode (red1, OUTPUT);
pinMode (yellow1, OUTPUT);
pinMode (green1, OUTPUT);

// Traffic light two
pinMode (red2, OUTPUT);
pinMode (yellow2, OUTPUT);
pinMode (green2, OUTPUT);
}
void loop () {
changeLights ();
delay(10000);
}

void changeLights () {
// Both yellow lights turns on
digitalWrite(green1, LOW);
digitalWrite(yellow1, HIGH);
digitalWrite(yellow2, HIGH);
delay (7000);

// turns off both yellow and turns on red1 and green2
digitalWrite(yellow1, LOW);
digitalWrite(red1, HIGH);
digitalWrite(yellow2, LOW);
digitalWrite(red2, LOW);
digitalWrite(green2, HIGH);
delay(7000);

// both of the yellow lights turns on
digitalWrite(yellow1, HIGH);
digitalWrite(yellow2, HIGH);
digitalWrite(green2, LOW);
delay(3000);

// turns off both yellow light and turns on grren1 and red2
digitalWrite(green1, HIGH);
digitalWrite(yellow1, LOW);
digitalWrite(red1, LOW);
digitalWrite(yellow2, LOW);
digitalWrite(red2, HIGH);
delay(7000);
}
Рекомендации по теме
Комментарии
Автор

thank you so much for this! I’m currently having a little trouble understanding how to use tinkercad so this is perfect.

girlwitheblanket
Автор

Hello thanks for the effort, but i noticed an anomaly,
The Red light is followed by the green light so the sequence is:
RED => green => yellow => red => green …
Not Red yellow green, thats why actually i checked the video

takieddine
Автор

How were u able to make the LEDs have so much power, mine, one had a lot of power and the others didn’t.
Please help

bethiraguha
Автор

Una pregunta de donde saco el codigo de las letras

hhccyvv
Автор

Does anyone know the real code I need it for a project.

timothybrigette