OUT_RGBLED+2xSwitches02 by yasusanto

Cloned from Sketch OUT_RGBLED+2xSwitches01 by yasusanto

This sketch is missing a short description

RGB-LED and 2x Momentary Switches 02

This program makes Arduino to read signals (on/off) from two momentary switches (it reads signals about every 50 milliseconds). The program then instruct Arduino to increase the light intensity of one of colours (RGB) of the RGB-LED according to the switch combination.

  • If both switches are pressed, Blue becomes 1 step brighter (maximum 250).
  • If switch 1 is pressed, Red becomes 1 step brighter (maximum 250).
  • If switch 2 is pressed, Green becomes 1 step brighter (maximum 250).

When any of RGB values exceeded ‘250’, it resets to ‘0’.

printRGB is a custom function to print RGB value to Serial Monitor.

rgbPattern is a custom function to change RGB value of RGB-LED. Try changing any of RGB values to see if you can find the colour you like.

"+=" adds the number that follows the sign to the preceding variable and store the result to the same variable. See Increment Compound in Arduino’s language reference for more information.

enter image description here

Embed This Sketch

Use the following HTML code to embed the sketch code above in your blog or website.

<iframe style="height: 510px; width: 100%; margin: 10px 0 10px;" allowTransparency="true" src="https://codebender.cc/embed/sketch:132190" frameborder="0"></iframe>

Embed The Serial Monitor

You can also embed the Serial Monitor section! Just use this HTML code.

<iframe style="height: 510px; width: 100%; margin: 10px 0 10px;" allowTransparency="true" src="https://codebender.cc/embed/serialmonitor" frameborder="0"></iframe>