To use this file copy and paste this:    // #URL-lib "http://pin1.org/forthlib/flb/Examples/p0-31.fth"   into BV Terminal 3 or here to download.

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // flash an led on p0.31 // This is the simplest example of Forth code and in this // file you can see how the required library is automatically // downloaded form the pin1.org site // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

// REQUIRES: // #URL-lib "http://pin1.org/forthlib/flb/General/pinsel.flb"

// CONSTANTS: // There are no constants but the following variable is defined // in order to reflect the current state of the port. variable tog


Full Contents of File

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// flash an led on p0.31
// This is the simplest example of Forth code and in this
// file you can see how the required library is automatically
// downloaded form the pin1.org site
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

// REQUIRES:
// #URL-lib "http://pin1.org/forthlib/flb/General/pinsel.flb"

// CONSTANTS:
// There are no constants but the following variable is defined
// in order to reflect the current state of the port.
variable  tog

// set p31 to an output, -ve numbers are used for port 1 and
// +ve for port 0
: p0.31-setup
        31  io-out      // set p0.31 to o/p
        0  tog  !          // set variable to 0
;

// turns on or off using p!
// 1 = on, 0 = off
// ( 0|1 ---)
: p0.31     
    0=  31  p!
;       

// toggles p0.31, if its on, claaing this will switch it off
// and vice-versa
: p0.31-toggle
        tog  @  0=  dup  tog  !
        p0.31
;

: go
        p0.31-setup
        begin
                100  ms
                p0.31-toggle
                key?
        until
;