1

Topic: How to change LED color

Hello,
I just want simply, change an object color via the sketch.
Example a LED would be green if a relay is on , and red if a relay is off. So color changed by the sketch decision.
Would it be possible?
Thanks

2

Re: How to change LED color

You can use LED element. https://remotexy.com/en/help/indications/led/

3

Re: How to change LED color

Thanks for replying, but I'm very confusing abaout how this works!
Could you give me a very simple example of how to display a red led, wait 1 second, change the led color to blue?

4

Re: How to change LED color

barbichonbd wrote:

Thanks for replying, but I'm very confusing abaout how this works!
Could you give me a very simple example of how to display a red led, wait 1 second, change the led color to blue?

When you configure an LED on the interface, you can choose 1 to 3 colours, Red, Green, and Blue.

For each colour you "enable" you get a variable declared in the interface code. Each variable can be sent a value corresponding to the brightness of that colour, 0 to 255.

More than one colour, you are able to "mix" them.  In this example for RGB_led I have configured all 3 colours, and the interface code generates me 3 output variables ...

    // output variables
  uint8_t RGB_led_r; // =0..255 LED Red brightness 
  uint8_t RGB_led_g; // =0..255 LED Green brightness 
  uint8_t RGB_led_b; // =0..255 LED Blue brightness 

If you only want Red and Blue, don't check the Green box in the LED configuration.

A Red LED would be LED_r = 255, LED_b = 0
A Blue LED would be LED_r = 0, LED_b = 255

If you set them both to 255, you would get Magenta, i.e. Red and Blue mixed.  Of course you can use any values in between to get different "hues" and brightnesses.

Your sketch can write separate values to those variables to produce a total of 256 x 256 x 256 colours, just over 16 million combinations !!

Don't use the "delay()" function for waiting, the interface to your phone will almost certainly disconnect. Instead keep a track of elapsed milliseconds. There are loads of tutorials on the internet for doing timing without using delay()

2B, or not 2B, that is the pencil ...