LED
Indicator copies normal LED on the device's screen. Information is transmitted from the controller to the smartphone. LED can change the brightness of each of the three primary colors - red, green, blue. Is also supported by a mixture of colors, and you can display any color.
Data
Data | Type | Values |
Intensity of the red | unsigned char | 0..255 - intensity of the red color |
Intensity of the green | unsigned char | 0..255 - intensity of the green color |
Intensity of the blue | unsigned char | 0..255 - intensity of the blue color |
Settings
- Variable name - name of the LED and the variable in the source code for the microcontroller, allow to set a name for the variable of C rules.
- Red - use the red component of the color (default).
- Green - use the green component of the color
- Blue - use the blue component of the color
Code example
To set the glow of one of the colors of the LED, it is necessary to write in the appropriate field value 255, it is the maximum color saturation:
RemoteXY.led_1_r = 255; // turn on red color
The example shows the use of partial brightness LED:
RemoteXY.led_1_r = 128; // 50% brightness
RemoteXY.led_2_r = 64; // 25% brightness
To turn off the indicator just write in the corresponding field value 0:
RemoteXY.led_1_r = 0; // turn off red color
You can control any of the three colors of LED - red, green, and blue. The possibility of using each of the colors you set in the settings of the indicator when it is placed in the online editor. For each color in the structure RemoteXY there is a separate field in which to write the value from 0 to 255. When you enable two or more colors at the same time, the color indicator will be mixed.
An example that implements the LED as status indicator input pin 5 of the Arduino:
if (digitalRead(5) == HIGH) // if pin 5 enjoyed a high level voltage
RemoteXY.led_1_r = 255; // then turn on red light
else // else
RemoteXY.led_1_r = 0; // turn off red
The previous example, but written in a single line:
RemoteXY.led_1_r = (digitalRead(5)==HIGH)?255:0;
An example that implements the brightness of the LED depending on input voltage on analog pin A0 Arduino:
// get the value from the ADC pins A0, which will be 0..1023
int adc = analogRead(A0);
// convert the ADC value to the range of values of the LED
RemoteXY.led_1_r = adc / 4;