\ ********************************************************************* 
\ command Traffic Lights with LoRa 
\    Filename:      distantTrafficLights.txt 
\    Date:          01 feb 2022  
\    Updated:       01 feb 2022 
\    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 ---  |  --- 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 
 
\ old code 
\  2 defPIN: ledGREEN         \ green  LED on GPIO2 
\ 21 defPIN: ledYELLOW        \ yellow LED on GPIO21 
\ 17 defPIN: ledRED           \ red    LED on GPIO17 
 
\ new code 
27 defPIN: ledGREEN         \ green  LED on GPIO2 
26 defPIN: ledYELLOW        \ yellow LED on GPIO21 
25 defPIN: ledRED           \ red    LED on GPIO17 
 
: LEDinit 
    ledGREEN    output 
    ledYELLOW   output 
    ledRED      output 
    ; 
 
 
 

Legal: site web personnel sans commerce / personal site without seling