Skip to content

Commit 59bffe9

Browse files
committed
Added E27
1 parent a295888 commit 59bffe9

7 files changed

+220
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
Bas on Tech - Traffic light step 1
3+
4+
This course is part of the courses on https://arduino-tutorials.net
5+
6+
(c) Copyright 2020 - Bas van Dijk / Bas on Tech
7+
This code and course is copyrighted. It is not allowed to use these courses commercially
8+
without explicit written approval
9+
10+
YouTube: https://www.youtube.com/c/BasOnTech
11+
Facebook: https://www.facebook.com/BasOnTechChannel
12+
Instagram: https://www.instagram.com/BasOnTech
13+
Twitter: https://twitter.com/BasOnTech
14+
15+
*/
16+
17+
void setup()
18+
{
19+
// Set pin 8 t/m 10 as output
20+
pinMode(8, OUTPUT);
21+
pinMode(9, OUTPUT);
22+
pinMode(10, OUTPUT);
23+
24+
// Set all output to LOW in order to turn all LEDs off
25+
digitalWrite(8, LOW);
26+
digitalWrite(9, LOW);
27+
digitalWrite(10, LOW);
28+
}
29+
30+
void loop()
31+
{
32+
// Red
33+
digitalWrite(8, HIGH);
34+
delay(5000);
35+
digitalWrite(8, LOW);
36+
37+
// Green
38+
digitalWrite(10, HIGH);
39+
delay(5000);
40+
digitalWrite(10, LOW);
41+
42+
// Orange / Yellow
43+
digitalWrite(9, HIGH);
44+
delay(1000);
45+
digitalWrite(9, LOW);
46+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
Bas on Tech - Traffic light step 2
3+
4+
This course is part of the courses on https://arduino-tutorials.net
5+
6+
(c) Copyright 2020 - Bas van Dijk / Bas on Tech
7+
This code and course is copyrighted. It is not allowed to use these courses commercially
8+
without explicit written approval
9+
10+
YouTube: https://www.youtube.com/c/BasOnTech
11+
Facebook: https://www.facebook.com/BasOnTechChannel
12+
Instagram: https://www.instagram.com/BasOnTech
13+
Twitter: https://twitter.com/BasOnTech
14+
15+
*/
16+
17+
18+
const int PIN_RED = 8;
19+
const int PIN_YELLOW = 9;
20+
const int PIN_GREEN = 10;
21+
22+
void setup()
23+
{
24+
// Set pin 8 t/m 10 as output
25+
pinMode(PIN_RED, OUTPUT);
26+
pinMode(PIN_YELLOW, OUTPUT);
27+
pinMode(PIN_GREEN, OUTPUT);
28+
29+
// Set all output to LOW in order to turn all LEDs off
30+
digitalWrite(PIN_RED, LOW);
31+
digitalWrite(PIN_YELLOW, LOW);
32+
digitalWrite(PIN_GREEN, LOW);
33+
}
34+
35+
void loop()
36+
{
37+
// Red
38+
digitalWrite(PIN_RED, HIGH);
39+
delay(5000);
40+
digitalWrite(PIN_RED, LOW);
41+
42+
// Green
43+
digitalWrite(PIN_GREEN, HIGH);
44+
delay(5000);
45+
digitalWrite(PIN_GREEN, LOW);
46+
47+
// Orange / Yellow
48+
digitalWrite(PIN_YELLOW, HIGH);
49+
delay(1000);
50+
digitalWrite(PIN_YELLOW, LOW);
51+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
Bas on Tech - Traffic light step 3
3+
4+
This course is part of the courses on https://arduino-tutorials.net
5+
6+
(c) Copyright 2020 - Bas van Dijk / Bas on Tech
7+
This code and course is copyrighted. It is not allowed to use these courses commercially
8+
without explicit written approval
9+
10+
YouTube: https://www.youtube.com/c/BasOnTech
11+
Facebook: https://www.facebook.com/BasOnTechChannel
12+
Instagram: https://www.instagram.com/BasOnTech
13+
Twitter: https://twitter.com/BasOnTech
14+
15+
*/
16+
17+
18+
const int PIN_RED = 8;
19+
const int PIN_YELLOW = 9;
20+
const int PIN_GREEN = 10;
21+
22+
const int DELAY_RED = 5000;
23+
const int DELAY_YELLOW = 1000;
24+
const int DELAY_GREEN = 5000;
25+
26+
void setup()
27+
{
28+
// Set pin 8 t/m 10 as output
29+
pinMode(PIN_RED, OUTPUT);
30+
pinMode(PIN_YELLOW, OUTPUT);
31+
pinMode(PIN_GREEN, OUTPUT);
32+
33+
allOff();
34+
}
35+
36+
void loop()
37+
{
38+
// Red
39+
digitalWrite(PIN_RED, HIGH);
40+
delay(DELAY_RED);
41+
digitalWrite(PIN_RED, LOW);
42+
43+
// Green
44+
digitalWrite(PIN_GREEN, HIGH);
45+
delay(DELAY_GREEN);
46+
digitalWrite(PIN_GREEN, LOW);
47+
48+
// Orange / Yellow
49+
digitalWrite(PIN_YELLOW, HIGH);
50+
delay(DELAY_YELLOW);
51+
digitalWrite(PIN_YELLOW, LOW);
52+
}
53+
54+
// Set all output to LOW in order to turn all LEDs off
55+
void allOff()
56+
{
57+
digitalWrite(PIN_RED, LOW);
58+
digitalWrite(PIN_YELLOW, LOW);
59+
digitalWrite(PIN_GREEN, LOW);
60+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
Bas on Tech - Traffic light step 4
3+
4+
This course is part of the courses on https://arduino-tutorials.net
5+
6+
(c) Copyright 2020 - Bas van Dijk / Bas on Tech
7+
This code and course is copyrighted. It is not allowed to use these courses commercially
8+
without explicit written approval
9+
10+
YouTube: https://www.youtube.com/c/BasOnTech
11+
Facebook: https://www.facebook.com/BasOnTechChannel
12+
Instagram: https://www.instagram.com/BasOnTech
13+
Twitter: https://twitter.com/BasOnTech
14+
15+
*/
16+
17+
const int PIN_RED = 8;
18+
const int PIN_YELLOW = 9;
19+
const int PIN_GREEN = 10;
20+
21+
const int DELAY_RED = 5000;
22+
const int DELAY_YELLOW = 1000;
23+
const int DELAY_GREEN = 5000;
24+
25+
void setup()
26+
{
27+
// Set pin 8 t/m 10 as output
28+
pinMode(PIN_RED, OUTPUT);
29+
pinMode(PIN_YELLOW, OUTPUT);
30+
pinMode(PIN_GREEN, OUTPUT);
31+
32+
allOff();
33+
}
34+
35+
void loop()
36+
{
37+
toggleLED(PIN_RED, DELAY_RED);
38+
toggleLED(PIN_GREEN, DELAY_GREEN);
39+
toggleLED(PIN_YELLOW, DELAY_YELLOW);
40+
}
41+
42+
// Toggles the given LED with the given delay
43+
void toggleLED(int led_pin, int led_delay)
44+
{
45+
digitalWrite(led_pin, HIGH);
46+
delay(led_delay);
47+
digitalWrite(led_pin, LOW);
48+
}
49+
50+
// Set all output to LOW in order to turn all LEDs off
51+
void allOff()
52+
{
53+
digitalWrite(PIN_RED, LOW);
54+
digitalWrite(PIN_YELLOW, LOW);
55+
digitalWrite(PIN_GREEN, LOW);
56+
}
130 KB
Binary file not shown.
182 KB
Loading

E27-traffic-light/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Arduino traffic light
2+
Part of the Bas on Tech Arduino YouTube tutorials - More info at https://arduino-tutorials.net
3+
4+
Subscribe to the Bas on Tech YouTube channel via http://www.youtube.com/c/BasOnTech?sub_confirmation=1
5+
6+
## The circuit
7+
![alt text](./E27-traffic-light.png "the circuit")

0 commit comments

Comments
 (0)