Component: LED (Generic, RGB) (LED)
Author | Matrix Ltd |
Version | 1.3 |
Category | LED |
Contents
LED (Generic, RGB) component
An LED with red, green and blue elements that can be mixed together to produce almost any colour at any brightness.
Component Source Code
Please click here for the component source code: FC_Comp_Source_RGB_LED.fcfx
Detailed description
No detailed description exists yet for this component
Examples
Tricolour LEDs generally have four pins and come in both common anode and common cathode configurations and must be wired to suit. The RGBLED component has a property allowing you to configure which LED type your using.
An active high LED will light when the microcontroller pin is outputting a logic 1 and be off when the microcontroller pin is outputting a logic 0 or in input mode.
An active low LED will light when the microcontroller pin is outputting a logic 0 and be off when the microcontroller pin is outputting a logic 1 or in input mode.
Six pin tricolour LEDs can simply be treated as three individual standards LEDs.
The series resistor acts to protect each individual LED from damage due to excess current. The value of resistor used can be changed based on the brightness of the LED and power consumption. Usually the three colour LEDs have different characteristics from each other so a different protection resistor should be provided for each LED to balance the LEDs output.
This LED Calculator tool is a good resource for calculating the correct LED series protection resistor.
This example for the RGB LED uses three analogue sliders to set the output colour of the LED.
The LED Colour is output to the LED using the Timer interrupt which calls the RGB LED Tick function.
The RGB LED properties include a setting for "Colour Bit Size" which sets the period for the LED colour PWM. The "Rollover Value" property shows the number of interrupts required for each PWM period so the timer interrupt should be running fast enough to allow the LED to output several periods per second. Persistence of vision can normally no longer detect any flickering light above approx 24Hz.
For a constant none flickering LED you can work out the minimum interrupt frequency like this.
30Hz * Rollover Value = Minimum interrupt frequency
30Hz * 256 = 7680Hz
60Hz * 64 = 3840Hz
Each LED colour channel can be set from 0 (minimum) to the rollover value - 1 (maximum). Therefore with a colour channel bit size of 8 there are theoretically 16777216 colours available 2^(8*3). With a colour bit size of 4 the available number of colours that can be generated drops to 4096, 2^(4*3).
Downloadable macro reference
Disable | |
Disables the RGB LED. It will no longer respond to color changes. | |
- VOID | Return |
Enable | |
Enables the RGB LED. This must be done before the LED can be lit or the color changed. | |
- VOID | Return |