top of page

Repeat Command Test

This test program use repeat in all of the various manners it can be used in.

Program


---

Repeat Command Test Program

---


prog_vars =

d/count 1

d/rand_no 0

d/servo_pos 0

d/do_reps 0

prog_vars.


prog_start =

print "Repeat Test Program"

pticks 5

/count 0

/rand_no 0

prog_start.


prog_loop =


print "Main Loop /count"

inc /count


-- flash user led 10 times with 50ms delay.

repeat 10 -> pulse d1 50


-- Print rand no -100 to 100

rand -100 100 -> /rand_no|print "RND1 /rand_no"


-- Display 5 random numbers between 1 - 100

repeat 5 -> rand 1 100 -> /rand_no|print "RND2 /rand_no"


repeat 5

rand 1 100 -> /rand_no

print "RND3 /rand_no"

repeat.

-- Exit the repeat if we get a rand no > 25

repeat 5

rand 1 100 -> /rand_no

print "RND4 /rand_no"

any /rand_no > 25 -> print "Exit rep"|skipout

repeat.

-- Flash some lights

repeat 10 -> tg a1|tg a5|tg d1

-- Step a servo through 180 deg use 18 reps

div 180 10 -> /do_reps

repeat /do_reps ->

print "Servo pos /servo_pos"

-- Set the servo position.

svp a1 /servo_pos

-- Leave the repeat early.

any /servo_pos >= 9 -> skipout


-- Inc the /servo_pos by 10

inc /servo_pos 10

repeat.

-- exit after 15 runs.

any /count >= 15 -> print "Qu /count"|exitprog

prog_loop.


prog_stop =

print "Prog STOPPED!"

prog_stop.




bottom of page