Skip to content

Commit e6a9a31

Browse files
authored
Merge pull request #9 from sarabgi/branch1
traffic light added
2 parents 0d9afd5 + a7902a8 commit e6a9a31

File tree

5 files changed

+162
-0
lines changed

5 files changed

+162
-0
lines changed

traffic_light (3)/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
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.
2+
3+
## The challenge
4+
5+
Modify code to add a turn signal (a white LED connected to pin 13).
6+
7+
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.
8+
9+
10+

traffic_light (3)/diagram.json

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
"version": 1,
3+
"author": "Uri Shaked",
4+
"editor": "wokwi",
5+
"parts": [
6+
{ "type": "wokwi-arduino-uno", "id": "uno", "top": 145.98, "left": 47.77, "attrs": {} },
7+
{
8+
"type": "wokwi-led",
9+
"id": "led-r",
10+
"top": -212.4,
11+
"left": 208.2,
12+
"rotate": 90,
13+
"attrs": { "color": "red" }
14+
},
15+
{
16+
"type": "wokwi-led",
17+
"id": "led-y",
18+
"top": -182.7,
19+
"left": 207.91,
20+
"rotate": 90,
21+
"attrs": { "color": "yellow" }
22+
},
23+
{
24+
"type": "wokwi-led",
25+
"id": "led-g",
26+
"top": -149.51,
27+
"left": 212.26,
28+
"rotate": 90,
29+
"attrs": { "color": "green" }
30+
},
31+
{
32+
"type": "wokwi-resistor",
33+
"id": "r1",
34+
"top": -11.34,
35+
"left": 223.46,
36+
"attrs": { "value": "1000" }
37+
},
38+
{
39+
"type": "wokwi-resistor",
40+
"id": "r2",
41+
"top": 19.8,
42+
"left": 225.6,
43+
"attrs": { "value": "1000" }
44+
},
45+
{
46+
"type": "wokwi-resistor",
47+
"id": "r4",
48+
"top": 54.47,
49+
"left": 219.54,
50+
"attrs": { "value": "1000" }
51+
},
52+
{
53+
"type": "wokwi-led",
54+
"id": "led-r1",
55+
"top": -194.3,
56+
"left": 25,
57+
"rotate": 90,
58+
"attrs": { "color": "red" }
59+
},
60+
{
61+
"type": "wokwi-led",
62+
"id": "led-g1",
63+
"top": -167.15,
64+
"left": 25.82,
65+
"rotate": 90,
66+
"attrs": { "color": "green" }
67+
},
68+
{
69+
"type": "wokwi-resistor",
70+
"id": "r3",
71+
"top": 70.16,
72+
"left": -1.57,
73+
"attrs": { "value": "1000" }
74+
},
75+
{
76+
"type": "wokwi-resistor",
77+
"id": "r5",
78+
"top": 101.3,
79+
"left": 0.57,
80+
"attrs": { "value": "1000" }
81+
}
82+
],
83+
"connections": [
84+
[ "uno:GND.1", "led-r:C", "black", [ "v-12", "*", "h-16" ] ],
85+
[ "uno:GND.1", "led-y:C", "black", [ "v-12", "*", "h-16" ] ],
86+
[ "uno:GND.1", "led-g:C", "black", [ "v-12", "*", "h-16" ] ],
87+
[ "r1:1", "led-g:A", "green", [ "v0" ] ],
88+
[ "r1:2", "uno:9", "green", [ "h57.89", "v91.25", "h-158.81", "v40.09" ] ],
89+
[ "r2:2", "uno:11", "gold", [ "h38.8", "v73.95", "h-158.21" ] ],
90+
[ "r2:1", "led-y:A", "yellow", [ "h-16.32", "v-181.81" ] ],
91+
[ "r4:2", "uno:8", "red", [ "v34.85", "h-85.54" ] ],
92+
[ "r4:1", "led-r:A", "red", [ "h-18.07", "v-170.21", "h0.57", "v-77.71" ] ],
93+
[ "r5:2", "uno:7", "green", [ "v3.88", "h177.2" ] ],
94+
[ "r3:2", "uno:6", "red", [ "v0.57", "h188.84" ] ],
95+
[ "r3:1", "led-r1:A", "red", [ "h-27.03", "v-147.05" ] ],
96+
[ "led-g1:A", "r5:1", "green", [ "h0" ] ],
97+
[ "led-g1:C", "uno:GND.1", "black", [ "h-61.18", "v140.58", "h195.92", "v29.4" ] ],
98+
[ "led-r1:C", "uno:GND.1", "black", [ "h-62.24", "v212.24", "h202.35" ] ]
99+
]
100+
}

traffic_light (3)/libraries.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TaskScheduler
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
int goled = 9; //Traffic light Led’s and pins
2+
int readyled = 11;
3+
int stopled = 8;
4+
int bawaltumawid = 6;
5+
int pwedetumawid = 7;
6+
7+
8+
void setup(){
9+
pinMode(goled, OUTPUT); //Pinmodes of the leds
10+
pinMode(readyled, OUTPUT);
11+
pinMode(stopled, OUTPUT);
12+
pinMode(bawaltumawid, OUTPUT);
13+
pinMode(pwedetumawid, OUTPUT);
14+
}
15+
void loop(){
16+
digitalWrite(goled, HIGH); //Green on for 7 seconds
17+
digitalWrite(bawaltumawid, HIGH); //Pedestrian RedLed on
18+
delay(110000);
19+
// flash the ped green
20+
for (int x=0; x<8; x++) {
21+
digitalWrite(goled, HIGH);
22+
delay(250);
23+
digitalWrite(goled, LOW);
24+
delay(250);
25+
}
26+
digitalWrite(goled, LOW); //Green off,
27+
28+
digitalWrite(readyled, HIGH); // readyled on
29+
30+
delay(10000);
31+
// flash the green
32+
33+
digitalWrite(readyled, LOW);//readyled off,stopled on
34+
digitalWrite(stopled, HIGH);
35+
digitalWrite(bawaltumawid, LOW); //Pedestrian RedLed off
36+
digitalWrite(pwedetumawid, HIGH); //Pedestrian GreenLed on
37+
delay(90000);
38+
39+
for (int x=0; x<8; x++) { //flash the pedestrian green led
40+
digitalWrite(pwedetumawid, HIGH);
41+
delay(250);
42+
digitalWrite(pwedetumawid, LOW);
43+
delay(250);
44+
}
45+
digitalWrite(pwedetumawid, LOW);//Pedestrian GreenLed off
46+
digitalWrite(stopled, LOW);//stopled off
47+
48+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Downloaded from https://wokwi.com/projects/343669912007344722
2+
3+
Simulate this project on https://wokwi.com

0 commit comments

Comments
 (0)