SPLat Logo

EC1 meets Android meets RGB

This EasyStep shows you how Easy it is to get an EC1 to control an RGB LED from an Android device via Bluetooth.

The program combines three other EasySteps, which you must have done first (and have all the hardware for) for this one to make sense. They are:

It should take you way less than an hour to do this EasyStep, depending on how deeply you delve into the SPLat code. The video clip below shows you the end result using a rolled up sheet of paper as a diffuser.

To run the program

I am going to jump straight into the program. This EasyStep really is just a remix of previous steps, plus a new program. The program is not overly complicated. If you studied the previous ones most of it should be obvious. There's one new element, which has a "mouseover" explanation.

The program

The full program is listed below. To show/hide the program listing click here. One single pop-up annotation is on an instruction that is almost certainly new to you. It is marked like this:


Place your mouse over the ;[...] to see the pop-up.

;RGB/SimpleHMI colourwheel demo for EC1

aoRed           oEQU    0   
aoGrn           oEQU    1   
aoBlu           oEQU    2   

HMIPort         EQU     252		;Assign a value to a symbolic name

#       Open_Serial Port(HMIPort) User(9600,8,N)   
#       HMI Port(HMIPort) ConnectEvent(evConnect)  ;Declare the handler for the Connected event

        GoSub           TopMenu         ;Paint the initial screen
        LaunchTask      HeartBeat
;Paint the home screen on SimpleHMI aka Top Menu           
        GoSub   TopMenu
;------ Display Colour wheel ------------------
# HMI Reset() Cls() HideAllButtons()
# HMI ColourWheel(evColourWheel)
;New colour input from the colour wheel. RGB values are 0-255
        fLoadQ          0.003923      ;Scale factor

        aCOMRx_fGetNum  HMIPort,255   ;Retrieve the Red value
        fMul                          ;Scale from 0-255 to 0-.99999999
        fAnout          aoRed         ;Set the red LED

        aCOMRx_fGetNum  HMIPort,255   ;Retrieve the Green value
        fAnout          aoGrn   

        aCOMRx_fGetNum  HMIPort,255   ;Retrieve the Blue value
        fAnout          aoBlu   

;Heartbeat task
        On              0
        Pause           10
        Off             0
        Pause           40
        GoTo            HeartBeat