top of page

Korahs Random Lights

This program will randomly flash 5 LEDs attached to Port C using a random number to decide which LEDs are lit.

Program


---

Korahs Random Lights Program

This program will randomly flash 5

leds attached to port C using a

random number to decide which LEDs

are lit.

---


prog_vars =


-- Holds the random number

d/random 0

d/count 0

prog_vars.


prog_start =

print "Korahs Random Lights Program"

/random 0

prog_start.


prog_loop =

-- main program loop

-- Increase the /count by 1

inc /count


-- Get a new random number between 0 and 6.

rand 0 6 -> /random

print "Count /count rand no /random"

-- Use the ant the determine which LED we should light

-- up based upon the random number.

-- A 6 will turn them all off.

ant /random ->

= 1 -> c1 1

= 2 -> c2 1

= 3 -> c3 1

= 4 -> c4 1

= 5 -> c5 1

-> coff

ant.

-- Check if we shoukd exit.

any /count > 1000 -> exitprog


prog_loop.


prog_stop =

print "Bye"


prog_stop.



bottom of page