Random Light Flasher Using the rand and toggle Commands

This program uses the rand and toggle commands to randomly
flash LEDs connected to port A. The rand command generates a
number between 1 and 5 and stores it in the /rand_no var.
The tg (toggle command) then uses the /rand_no as an argument to
toggle the corresponding led on port A.
This is possible because the toggle command uses channels.

Program


---

Random Light Flasher Program using the rand and toggle comamnds

This program uses the rand and toggle commands to randomly

flash LED's connected to port A. The rand command generates a

number between 1 and 5 and stores it in the /rand_no var.

The tg (toggle command) then uses the /rand_no as an argument to

toggle the corresponding led on port A.

This is possible because the toggle command uses channels.

---

prog_vars =

d/runs_to_do 50

d/runs_done 0

d/rand_no 0

prog_vars.


prog_start =


aoff

prog_start.


prog_loop =


-- Do /runs_to_do runs

repeat /runs_to_do ->

-- Get a random number

rand 1 15 -> /rand_no

"rand no /rand_no run no /runs_done"

-- Toggle the value of the channel no in the /rand_no var

tg /rand_no

repeat.


-- dec the runs to do and inc runs done

dec /runs_to_do

inc /runs_done

-- exit after runs done

any /runs_done >= /runs_to_do -> exitprog

prog_loop.



prog_stop =

-- Turn the port A Leds off

aoff

print "Bye"

prog_stop.