Code: Alles auswählen
fl
\ fl word must be first on text paste operation - see wiki
\ FLASH AN LED by Professor Braino - updated byBrianBR
\ usingPROPFORTH3.4
\ load PropForth.spin into eeprom
\ teraterm set to 57600 baud 8 n 1 worked
\
\ each unit of functionality is implemented as s sseparate word
\ when each word is functioning correctly, string them together
\ Notice: The SLASH comment character \
\ causes interpreter to IGNORE everything to end of line INCLUDING CR-LF
\ so the echoed text is formatted different than the text file
\ Too many lines without CR-LR causes input buffer overrun
1000000 constant pin24
variable w-delay \ ( uses w@ W! time delay in milliseconds )
: !DELAY w-delay W! ; \ ( ms - ) ( store the milliseconds to wait )
: .DELAY w-delay W@ delms ; \ ( - ) ( wait for milliseconds in delay )
: pin24-output pin24 dira COG! ; \ ( - ) ( make pin24 output )
: pin24-hi pin24 outa COG! ; \ ( - ) ( make pin24 high LED ON )
: pin24-lo 0 outa COG! ; \ ( - ) ( make pin24 low LED OFF )
\ ... string them together...
: flash24 pin24-hi .DELAY pin24-lo .DELAY ;
\ ( - ) ( flash LED using DELAY )
\ ... and put it in a loop
: FLASHES pin24-output 0 do flash24 loop ;
\ ( number of flashes desired - )
\ After one has determined what code is needed, it is possible to
\ cram everything into a single word
\ doing everything all in one word is sometimes refered to as
\ write only code (write once - edit never again )
\ This can execute faster, and takes slightly less space
\ but can be confusing on larger applications
\ after the code has been left alone for a few days
: ALL-ONE-WORD \ ( flashes - )
1000000 dira COG! \ ( make pin16 output )
0 do \ flashes to 0 DO ...
1000000 outa COG! \ ( make pin16 high LED ON )
100 delms \ ( delay for 100 ms)
0 outa COG! \ ( make pin16 low LED OFF )
100 delms
loop ;
10 ALL-ONE-WORD
\ next use the other method
50 !DELAY
200 FLASHES