Arduino RGB LED Protocol

Controls the brightness of your RGB LED and its colors.

How to build a test circuit with an RGB LED and an Arduino Mega?
Arduino codes are included.

I. 'Welcome' event from microcontroller

Example

 c=welcome&id=QZ5M12&type=OzRgbLedController&pos=2&t=3

Parameters

Parameter Type Range Functionality
c String 'welcome' Identifies the welcome message.
type String 'OzRgbLedController' Determines the type of the device.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.
pos Byte 0-255 Determines the position of the device on the list of the ID manager of the microcontroller. Please make sure there are no other devices in the same position.
t Byte 0-255 Counts the number of events and responses sent combined. Counts from 0 to 255 then from 0 again.



II. Commands to microcontroller

'Set Switch' command

Turns the RGB LED on/off or changes brightness (PWM value) depending on the parameters provided. In the current version you cannot combine the two parameters: state and pwm. This is why you can see two different examples.

Example

//Turns on the RGB LED
c=setswitch&state=1&t=0&id=QZ5M12
//Sets PWM to 140
c=setswitch&pwm=140&t=1&id=QZ5M12

Parameters

Parameter Type Range Functionality
c String 'setswitch' Identifies the command.
state
(optional)
Bool 0,1 0 turns the RGB LED on, 1 turns it off.
pwm
(optional)
Byte 0-255 0 sets it to the lowest, 255 sets it to the highest brightness.
t Byte 0-255 Counts the number of commands sent. Counts from 0 to 255 then from 0 again.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.

Response

//The RGB LED has been turned on
c=setswitch_resp&state=1&id=QZ5M12&t=3
//The PWM has been set to 140
c=setswitch_resp&pwm=140&id=QZ5M12&t=4

Parameters

Parameter Type Range Functionality
c String 'setswitch_resp' Identifies the response.
state
(optional)
Bool 0,1 0 turned the RGB LED on, 1 turned it off.
pwm
(optional)
Byte 0-255 0 has set it to the lowest and 255 has set it to the highest brightness.
t Byte 0-255 Counts the number of events and responses sent combined. Counts from 0 to 255 then from 0 again.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.



'Set LED Color' command

Sets the color of the RGB LED by setting the brightness of each LED (red, green and blue).

Example

c=setrgbled&red=0&green=0&blue=255&t=2&id=QZ5M12

Parameters

Parameter Type Range Functionality
c String 'setrgbled' Identifies the command.
red Byte 0-255 The rate of red color.
green Byte 0-255 The rate of green color.
blue Byte 0-255 The rate of blue color.
t Byte 0-255 Counts the number of commands sent. Counts from 0 to 255 then from 0 again.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.

Response

c=setrgbled_resp&red=0&green=0&blue=255&id=QZ5M12&t=5

Parameters

Parameter Type Range Functionality
c String 'setrgbled_resp' Identifies the response.
red Byte 0-255 The rate of red color.
green Byte 0-255 The rate of green color.
blue Byte 0-255 The rate of blue color.
t Byte 0-255 Counts the number of events and responses sent combined. Counts from 0 to 255 then from 0 again.
id String 6 characters (numbers, uppercase and lowercase characters) The ID of the device which is chosen by the microcontroller.



III. Event from microcontroller

None

More information