Please wait while we prepare your presentation...
Available NOW on KickStarter!

Programming the SIB™


Introduction
SiB™ vs SID mode
Programs in SiB™ mode
Programs in SID mode


Sample Programs
- Door Bell
- Emergency Button
- Freezer Monitor
- I Love You
- Lights Demo
- Magnetic Alarm
- Motion Sensor
- Sweet Dreams
- Thermometer
- Water/Moisture Sensor
- Yes or No

Commands
A - Z
Configuration
GPIO
Programming
Time
Sensor
Messaging

Sample Programs: Sweet Dreams

Sweet Dreams program involves multiple components:
- a function for long-click that turns the SiB off.
- a function for short-click that changes the SiB color.
- a function to set the three-color LED to a specific color and brightness
- three main program loops for startup to determine the duration of the program.

The program has a few global variables:
col: The current color - a value from 0 to 6
loops: The number of times to loop through the pulse

The main loop:
PROG s ; PROG S declares a single-click program
SET col=0
POWER WIFI OFF ; WiFi power is turned off to save battery
NOSAVE ; The state of the program doesn't need to be saved, saves power
BUTTON S PS ; Detect 's' short presses, call the function PS
BUTTON L PL ; Detect the 'l' long presses, call the function PL
SET loops=60 ; 60 iterations at 10s each = 10 minutes


breath:
FOR i 1023 23 -50 ; the LED brightness is set from a scale of 1023 to 0
                  ; 1023 being off, and 0 being the brightest
                  ; this loop will iterate from 1023 to 23 by steps of 50
                  ; the variable "i" represents the brightness
                  ; this loop effectively 'fades in' the LED
setled ; call the function 'setled'
DL 250 ; delay 1/4 of a second
NEXT

; the same loop as above, but from 23 to 1023, fading out
FOR i 23 1023 50
setled
DL 250
NEXT

SET loops=loops-1 ; decrement the number of loops remaining
IF loops>0
LOOP breath ; returns execution to the label "breath"
EI
                        
The functions:
; this function is activated on short click
; it simply increments the color from 0 to 6, looping back to 0
FN PS
SET col=col+1
IF col>=7
SET col=0
EI

; this function is activated on long click
; it simply powers off the SiB
FN PL
HALT

; this function sets the LED to the specific color and brightness
; remember that "i" in the main loop represents the brightness
FN setled
IF col=0 ; 0 will be blue
WA blue i ; set blue to the brightness
WA red 1023 ; red and green to off
WA green 1023
EI
IF col=1 ; 1 is red
WA blue 1023
WA red i
WA green 1023
EI
IF col=2 ; 2 is green
WA blue 1023
WA red 1023
WA green i
EI
IF col=3 ; 3 is purple
WA blue i
WA red i
WA green 1023
EI
IF col=4 ; 4 is yellow
WA blue 1023
WA red i
WA green i
EI

IF col=5 ; 5 is cyan
WA blue i
WA red 1023
WA green i
EI
IF col=6 ; 6 is white
WA blue i
WA red i
WA green i
EI

Adding 20, and 30 minute options
The same program loop "PROG S" is repeated, with the only exception of having the value in LOOPS changed from 60 to 120, and 180. The program names with this change are "SS" for two short clicks, and "SSS" for three short clicks.
PROG ss
SET col=0
POWER WIFI OFF
NOSAVE
BUTTON S PS
BUTTON L PL
SET loops=120
breath:
FOR i 1023 23 -50
setled
DL 250
NEXT
FOR i 23 1023 50
setled
DL 250
NEXT
SET loops=loops-1
IF loops>0
LOOP breath
EI


PROG sss
SET col=0
POWER WIFI OFF
NOSAVE
BUTTON S PS
BUTTON L PL
SET loops=180
breath:
FOR i 1023 23 -50
setled
DL 250
NEXT
FOR i 23 1023 50
setled
DL 250
NEXT
SET loops=loops-1
IF loops>0
LOOP breath
EI


TO SUBMIT THIS PROGRAM:
Like all programs, this program must be submitted in multiple IMs.
FIRST, each function (FN) must be sent to the SiB in individual IMs
NEXT, each program (PROG) must be sent to the SiB in individual IMs
FINALLY, press your SiB!








Live Chat