Pages: [1]   Go Down
Author Topic: Rgb led with stop button?  (Read 795 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Thanks!
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 79
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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! smiley-lol
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 79
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh...Opps  smiley-grin

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! smiley

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.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 630
Posts: 49998
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
if(fade)
{
   // 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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 79
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

PaulS beat me to it....Hope your son likes it! smiley-lol
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 27
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Jr. Member
**
Karma: 0
Posts: 79
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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...smiley

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

Tell him I said hi!
Logged

Pages: [1]   Go Up
Jump to: