-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtrafficLights.txt
62 lines (54 loc) · 1.54 KB
/
trafficLights.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
\ *********************************************************************
\ manage traffic lights
\ Filename: trafficLights.txt
\ Date: 30/05/2021
\ Updated: 11/01/2023
\ File Version: 1.0
\ MCU: ESP32-WROOM-32
\ Forth: ESP32forth v 7.05
\ Copyright: Marc PETREMANN
\ Author: Marc PETREMANN
\ GNU General Public License
\ *********************************************************************
DEFINED? defPIN: invert
[if] include /spiffs/defpin.txt [then]
\ Use:
\ numGPIO defPIN: PD7 ( define portD pin #7)
2 defPIN: ledGREEN
21 defPIN: ledYELLOW
17 defPIN: ledRED
: LEDinit
ledGREEN output pinMode
ledYELLOW output pinMode
ledRED output pinMode
;
\ traficLights execute one light cycle
: trafficLights ( ---)
high ledGREEN pin 3000 ms low ledGREEN pin
high ledYELLOW pin 800 ms low ledYELLOW pin
high ledRED pin 3000 ms low ledRED pin
;
\ classic traffic lights loop
: lightsLoop ( ---)
LEDinit
begin
trafficLights
key? until
;
\ german trafic light style
: Dtraffic ( ---)
high ledGREEN pin 3000 ms low ledGREEN pin
high ledYELLOW pin 800 ms low ledYELLOW pin
high ledRED pin 3000 ms
ledYELLOW high 800 ms
\ simultaneous red and yellow ON
high ledRED pin \ simultaneous red and yellow OFF
high ledYELLOW pin
;
\ german traffic lights loop
: DlightsLoop ( ---)
LEDinit
begin
Dtraffic
key? until
;