\ ********************************************************************* \ manage traffic lights \ Filename: trafficLights.txt \ Date: 30/05/2021 \ Updated: 30/05/2021 \ File Version: 1.0 \ MCU: ESP32-WROOM-32 \ Forth: ESP32forth v 7.05 \ Copyright: Marc PETREMANN \ Author: Marc PETREMANN \ GNU General Public License \ ********************************************************************* \ alternative solution for "marker", (marker not defined in ESP32forth) DEFINED? --defPin [if] forget --defPin [then] create --defPin vocabulary defPins defPins definitions transfer pin transfer pinmode transfer HIGH transfer LOW transfer output forth definitions defPins also \ Use: \ numGPIO defPIN: PD7 ( define portD pin #7) : defPIN: ( GPIOx ---| value ; \ Turn a pin on, dont change others : high ( GPIOx -- ) HIGH swap pin ; \ Set GPIOx as output : output ( GPIOx -- ) output pinMode ; \ Turn a pin off, dont change others : low ( GPIOx -- ) LOW swap pin ; only forth also 2 defPIN: ledGREEN \ green LED on GPIO2 21 defPIN: ledYELLOW \ yellow LED on GPIO21 17 defPIN: ledRED \ red LED on GPIO17 : LEDinit ledGREEN output ledYELLOW output ledRED output ; \ traficLights execute one light cycle : trafficLights ( ---) ledGREEN high 3000 ms ledGREEN low ledYELLOW high 800 ms ledYELLOW low ledRED high 3000 ms ledRED low ; \ classic traffic lights loop : lightsLoop ( ---) LEDinit begin trafficLights key? until ; \ german trafic light style : Dtraffic ( ---) ledGREEN high 3000 ms ledGREEN low ledYELLOW high 800 ms ledYELLOW low ledRED high 3000 ms ledYELLOW high 800 ms \ simultaneous red and yellow ON ledRED low \ simultaneous red and yellow OFF ledYELLOW low ; \ german traffic lights loop : DlightsLoop ( ---) LEDinit begin Dtraffic key? until ;--- GPIOx )
Legal: site web personnel sans commerce / personal site without seling