Go Down

Topic: Rgb led with stop button? (Read 1 time) previous topic - next topic


Me and my 11 year old built a little project with an rgb led and a button. We're looking for a sketch to run it that will fade through all the colors and when it's at a color my son likes, he can press the button and freeze it on that color (its a night light).

Has anyone seen one out there? Trying to jump start his interest in learning how to code with something cool like this.



Sounds like a really cool project! Here is a site I think that contains exactly what you are looking for. If not, I apologize in advance. Here the link is: http://www.instructables.com/id/Arduino-RGB-led-controller/#step1

Although you will need a few extra components, I think its worth a try....Good luck! XD


Thanks, looks like this needs MOFSETS. I've gotten the fading to work without them but i'm looking for a sketch that'll stop on a certain color with a button press. I'm surprised there's not an existing sketch out there. Thanks again!


Oh...Opps  :D

You are welcome; I agree with you. Your project is simple, and a wonderful idea that I don't know why there isnt a sketch out there! :)

I will try to work on writing one, but I am only 13 and new to arduino, so I might run into some problems...I will try my best! Good luck on your project.


Reading the state of a switch is pretty simple - digitalRead(). Wiring a switch is pretty simple - connect one leg to ground and one leg to a digital pin, and enable the pullup resistor (digitalWrite(somePin, HIGH);).

Fading until the switch state changes to LOW is simple. Fade inside a if block:
Code: [Select]
  // Do the fading stuff

Defining fade as a boolean is trivial. Setting it to true initially is easy. Setting it to false when the switch is pressed is easy.


PaulS beat me to it....Hope your son likes it! XD


Thanks guys. This is great. Zack, you're an inspiration to my son and a really good guy!


Thanks guys. This is great. Zack, you're an inspiration to my son and a really good guy!

You are welcome. Am I an inspiration? I am honored...:)

I appreciate your kind words, and I will be willing to help you anytime!

Tell him I said hi!

Go Up