Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions traffic_light (3)/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
This sketch implements a traffic light using the [Arduino TaskScheduler Library](). It goes from red to green and back. Green light blinks before going back to yellow.

## The challenge

Modify code to add a turn signal (a white LED connected to pin 13).

The turn signal up 3 seconds after green, stays on for 3 seconds, then blinks for 5 seconds together with green (in sync with green), before switching back to yellow.



100 changes: 100 additions & 0 deletions traffic_light (3)/diagram.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"version": 1,
"author": "Uri Shaked",
"editor": "wokwi",
"parts": [
{ "type": "wokwi-arduino-uno", "id": "uno", "top": 145.98, "left": 47.77, "attrs": {} },
{
"type": "wokwi-led",
"id": "led-r",
"top": -212.4,
"left": 208.2,
"rotate": 90,
"attrs": { "color": "red" }
},
{
"type": "wokwi-led",
"id": "led-y",
"top": -182.7,
"left": 207.91,
"rotate": 90,
"attrs": { "color": "yellow" }
},
{
"type": "wokwi-led",
"id": "led-g",
"top": -149.51,
"left": 212.26,
"rotate": 90,
"attrs": { "color": "green" }
},
{
"type": "wokwi-resistor",
"id": "r1",
"top": -11.34,
"left": 223.46,
"attrs": { "value": "1000" }
},
{
"type": "wokwi-resistor",
"id": "r2",
"top": 19.8,
"left": 225.6,
"attrs": { "value": "1000" }
},
{
"type": "wokwi-resistor",
"id": "r4",
"top": 54.47,
"left": 219.54,
"attrs": { "value": "1000" }
},
{
"type": "wokwi-led",
"id": "led-r1",
"top": -194.3,
"left": 25,
"rotate": 90,
"attrs": { "color": "red" }
},
{
"type": "wokwi-led",
"id": "led-g1",
"top": -167.15,
"left": 25.82,
"rotate": 90,
"attrs": { "color": "green" }
},
{
"type": "wokwi-resistor",
"id": "r3",
"top": 70.16,
"left": -1.57,
"attrs": { "value": "1000" }
},
{
"type": "wokwi-resistor",
"id": "r5",
"top": 101.3,
"left": 0.57,
"attrs": { "value": "1000" }
}
],
"connections": [
[ "uno:GND.1", "led-r:C", "black", [ "v-12", "*", "h-16" ] ],
[ "uno:GND.1", "led-y:C", "black", [ "v-12", "*", "h-16" ] ],
[ "uno:GND.1", "led-g:C", "black", [ "v-12", "*", "h-16" ] ],
[ "r1:1", "led-g:A", "green", [ "v0" ] ],
[ "r1:2", "uno:9", "green", [ "h57.89", "v91.25", "h-158.81", "v40.09" ] ],
[ "r2:2", "uno:11", "gold", [ "h38.8", "v73.95", "h-158.21" ] ],
[ "r2:1", "led-y:A", "yellow", [ "h-16.32", "v-181.81" ] ],
[ "r4:2", "uno:8", "red", [ "v34.85", "h-85.54" ] ],
[ "r4:1", "led-r:A", "red", [ "h-18.07", "v-170.21", "h0.57", "v-77.71" ] ],
[ "r5:2", "uno:7", "green", [ "v3.88", "h177.2" ] ],
[ "r3:2", "uno:6", "red", [ "v0.57", "h188.84" ] ],
[ "r3:1", "led-r1:A", "red", [ "h-27.03", "v-147.05" ] ],
[ "led-g1:A", "r5:1", "green", [ "h0" ] ],
[ "led-g1:C", "uno:GND.1", "black", [ "h-61.18", "v140.58", "h195.92", "v29.4" ] ],
[ "led-r1:C", "uno:GND.1", "black", [ "h-62.24", "v212.24", "h202.35" ] ]
]
}
1 change: 1 addition & 0 deletions traffic_light (3)/libraries.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TaskScheduler
48 changes: 48 additions & 0 deletions traffic_light (3)/traffic_light.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
int goled = 9; //Traffic light Led’s and pins
int readyled = 11;
int stopled = 8;
int bawaltumawid = 6;
int pwedetumawid = 7;


void setup(){
pinMode(goled, OUTPUT); //Pinmodes of the leds
pinMode(readyled, OUTPUT);
pinMode(stopled, OUTPUT);
pinMode(bawaltumawid, OUTPUT);
pinMode(pwedetumawid, OUTPUT);
}
void loop(){
digitalWrite(goled, HIGH); //Green on for 7 seconds
digitalWrite(bawaltumawid, HIGH); //Pedestrian RedLed on
delay(110000);
// flash the ped green
for (int x=0; x<8; x++) {
digitalWrite(goled, HIGH);
delay(250);
digitalWrite(goled, LOW);
delay(250);
}
digitalWrite(goled, LOW); //Green off,

digitalWrite(readyled, HIGH); // readyled on

delay(10000);
// flash the green

digitalWrite(readyled, LOW);//readyled off,stopled on
digitalWrite(stopled, HIGH);
digitalWrite(bawaltumawid, LOW); //Pedestrian RedLed off
digitalWrite(pwedetumawid, HIGH); //Pedestrian GreenLed on
delay(90000);

for (int x=0; x<8; x++) { //flash the pedestrian green led
digitalWrite(pwedetumawid, HIGH);
delay(250);
digitalWrite(pwedetumawid, LOW);
delay(250);
}
digitalWrite(pwedetumawid, LOW);//Pedestrian GreenLed off
digitalWrite(stopled, LOW);//stopled off

}
3 changes: 3 additions & 0 deletions traffic_light (3)/wokwi-project.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Downloaded from https://wokwi.com/projects/343669912007344722

Simulate this project on https://wokwi.com