There are four user buttons on the kit, marked as SW1, SW2, SW3, and SW4. I want to realize a function to change the display color of the RGB LED by pressing different buttons:
Since this is my first time using this development environment, I don’t know much about many of the functions and have some wrong ideas. Let me first talk about the mistakes I made at the beginning. My initial idea was this:
I thought that a button element User Buttons Element could only realize one button function, so I put 3 User Buttons Elements, corresponding to the upper right button (SW1) to display red, the lower right button (SW2) to display green, and the upper left button (SW3) to display blue. However, the result of the program running was not as I expected. A strange result appeared. Only one of the three buttons responded, and the displayed color was not the color I arranged! This problem bothered me for a whole day, and later I finally found the problem. It turns out that the functions to be triggered by different buttons do not require the arrangement of different elements, but only need to be specified in the property field. Due to my lack of understanding, I took a detour. The final design is as follows:
Property settings of the upper right button, it displays red when pressed:
Property settings of the lower right button, it displays green when pressed:
Property settings of the upper left button, it displays blue when pressed:
Property settings of the lower left button, it turns off the LED when pressed:
Running results:
atmo project file:
P002.rar
(48.02 KB, downloads: 2)
【NXP Rapid IoT Review】Hello LED This content is originally created by EEWORLD forum user slotg. If you need to reprint or use it for commercial purposes, you must obtain the author’s consent and indicate the source