3. Hardware Operation

1. RGB LED light

16 views 2019-06-04 2019-06-04 peterletintech 0

Hardware requirement

  • M5GO

The RGB LED light bars are embedded into the left and right part of M5Go. Different colours can be shown to produce amazing lighting. This tutorial will show how to use buttons to change the colour of the screen and the light bars.

Step 1. Create a title and three labels and change the corresponding properties as shown below.

Change the text to “Press a button”, Change the x, y, text to 55, 224, Red respectively.

Change the x, y, text to 135, 224, Green respectively.

Change the x, y, text to 228, 224, Blue respectively.

Step 2. Drag three “Button A pressed” block to a blank place and “Lcd clear” block to under “Setup” block. (“Button A pressed” block)

“Lcd clear” block

Step 3. Change two button events from Button A to Button B and C.

Step 4. Drag the “Lcd fill” block into “Button A pressed” block.

Step 5. Change the fill colour to red for Button A, green for Button B and blue for Button C

Step 6. Test the final code.

Start.

When Button A is pressed, the screen is changed to red.

When Button B is pressed, the screen is changed to green.

When Button C is pressed, the screen is changed to blue.

Step 7. Change the hardware RGB LED bar colour to red for Button A, green for Button B and blue for Button C

Step 8. Test the final code

Start.

When Button A is pressed, the screen and LED bar are changed to red.

When Button B is pressed, the screen and LED bar are changed to green.

When Button C is pressed, the screen and LED bar are changed to blue.

Was this helpful?