An example of code using "program flow"

This is an example program written in Basic syntax. It checks two switches, if they are both pressed, it turns on an LED. if either is not pressed, it turns the LED off.


'===============================================================
' Create all objects
'===============================================================
Dim Switch1 as DIO
Dim Switch2 as DIO
Dim RedLed as DIO
Dim TheGate as Gate(2)


'===============================================================
' Define which I/O lines the objects use and
' which objects are inputs and which are outputs.
'===============================================================
Switch1.IOLine = 1: Switch1.Direction = cvInput
Switch2.IOLine = 2: Switch2.Direction = cvInput
RedLed.IOLine = 3: RedLed.Direction = cvOutput


'===============================================================
' Continuously check switches
'===============================================================
Do
If (Switch1 = cvPressed) and (Switch2 = cvPressed) then
LED = cvOn
Else
LED = cvOff
End If
Loop


Our program is now stuck checking the switches instead of doing other things.

A better way would be to create a "Virtual Circuit"


Home   Send mail and comments to: Savage Innovations.