top of page

Random Light Flasher Using the an Command

Random Light Flasher Program using the rand and ant comamnds

This program uses the rand and ant 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 ant command evaluates the value of /rand_no and toggles
the required LED on port A.
The program will run for /runs_to_do and stop.

Program


---

Random Light Flasher Program using the rand and ant comamnds

This program uses the rand and ant 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 ant command evaluates the value of /rand_no and toggles

the required LED on port A.

The program will run for /runs_to_do and stop.

---

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 5 -> /rand_no

"rand no /rand_no run no /runs_done"

ant /rand_no ->

= 1 -> tg a1

= 2 -> tg a2

= 3 -> tg a3

= 4 -> tg a4

= 5 -> tg a5

-> "out of range number /rand_no"

ant.

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.



bottom of page