This uses the JackBord block 3s internal USER LEDs to create a smart night light. A button attached to pin A1 is used to set the mode of operation of the light. Mode 1 produces warmer colors because it uses more red light. Mode 2 results in more daylight color because it uses more blue and green light.
Program
---
Smart Night Light Program
This uses the JackBord block 3's internal USER LEDs
to create a smart night light.
A button attached to pin A1 is used to set the
mode of operation of the light.
---
prog_vars =
d/led_no 0
d/red 0
d/green 0
d/blue 0
d/mode 1
prog_vars.
prog_start =
pclear
print "Smart Night Light Program Started"
-- turn all USER leds off
loff
-- Setup the button on A1 to set the mode
btp a1 set_mode
prog_start.
prog_loop =
"mode /mode"
-- Determien the mode we should be in
ant /mode ->
= 1 -> mode1
= 2 -> mode2
-> mode1
ant.
-- Set the color of the USER LEDs
l1 /red /green /blue
l2 /red /green /blue
l3 /red /green /blue
-- Wait a while
dly 1000
prog_loop.
set_mode =
-- called by the button press.
-- If we are in mode 1 goto mode 2.
ant /mode ->
= 1 -> /mode 2
= 2 -> /mode 1
-> /mode 1
ant.
print "New Mode /mode"
set_mode.
mode1 =
-- Use more Red colors by using more red in the light.
-- and use less of the other colors.
rand 100 255 -> /red
rand 0 100 -> /green
rand 0 100 -> /blue
mode1.
mode2 =
-- Use more daylight colors by using more blue and green in the light.
-- and use less red.
rand 0 100 -> /red
rand 100 255 -> /green
rand 100 255 -> /blue
mode2.
prog_stop =
print "prog stopped"
prog_stop.