- Connecting wire
- RGB LED light Unit
The RGB LED light consists of three NeoPixel RGB LED lights which can show lights with different RGB values. The brightness of each light can be set by programming.
This tutorial includes the use of buttons to control the brightness of the RGB LED light unit. The RGB LED light unit consists of three LED lights and each LED light can show one colour. The brightness of the light can be controlled by setting the different brightness by M5Flow.
Step 1. Drag two labels to the UI. One represents decreasing the brightness and one represents increasing the brightness.
Step 2. Change the properties of the two labels
Step 3. Add the RGB LED light unit by pressing the + button and select the unit with port A and click OK.
Step 4. Create a variable to control the brightness
Step 5. Drag the “set brightness to” block under “Setup” block to set the initial value of brightness.
Step 6. Drag the “Set rbg0 1 index rgb color” block to set the initial colour for different index for different LED lights.
Step 7. Drag two button events for increasing and decreasing the brightness.
Step 8. Drag the “change brightness by 1” block to Button A and Button C event and change the value of change to -50 for Button A and 50 for Button C.
Step 9. Drag the “Set rgb0 100 brightness” block to Button A and Button C event and replace the brightness value by “brightness” variable.
Step 10. Test the final code
Button C is pressed once. The brightness of the LED light is increased by 50 and becomes brighter.
Button A is press once to reduce the brightness to the original and once more to further reduce the brightness by 50.