HELP: RGB With 5 Switches, COOL IDEA, NEED HELP!!!!

Okay, me and my brother have this awesome ideea for RGB LED lights for his car, i know everything else on how to do em now, excpet the code isnt working good.

The general idea behind the project is this:

5 control swtiches, 1 for Red, Green, Blue, White(which is actually "lighten") and Black(which is actually "darken")
It is supposed to work that if you have red on, it will make red; green switch=green on. And then if you mix red and green it makes the coordinating color, but then the cool thing is is that if you have red on and then turn on the white switch, it would make say Pink. It "lightens" the color. And if you had red and black on it would make a maroonish color. And if all switches were on it would do a RGB Fade through.

I thought i could do this by using a bunch of if statements, like if(digitalRead(redSwitch) == LOW && digitalRead(greenSwitch) == LOW) {//and the loop} (And of course setting up the switch pins as inputs and digitalWriting them HIGH in void setup.

But it didnt quite work out the way i expected. It did some wierd things, and flickered wierd and things i dont even know..

So my question is is that is there a better way to do this kind of code? is there a different like loop im not doing and dont know about? I know most basic coding but i dont even know where to begin with for loops and all that jazz. i know the basics like if statements and such. I really just need help on this. If i helps i guess i will post the code i had but i was messing around with it so it wont be the same. It would be fantastic if someone could whip up some code for this, or at least the ooutline, and i could enter my pins and RGB Code, or if you have it, use it.

But really i just need help.

Thanks to all who read
Macke

i

Read this before posting a programming question

So my question is is that is there a better way to do this kind of code?

My question is: what code?

...exactly. I dont know how i should go about doing it. I had said that i was using "if" statements.

Im wondering how i should do this kind of code, to do what i listed above. 5 Switches, read with arduino, output to RGB Pins connected to transistors.

I dont understand much why you posted that, my whole post[above] is just that, the code i want done.

My question is just in what sorta way should i make this code. There isnt already a "code" done, i had messed around with if statements and such but none worked the way i wanted.

Thanks
Macke

tmacke17:
But it didnt quite work out the way i expected. It did some wierd things, and flickered wierd and things i dont even know..

How did you wire it up to begin with? Give us something to sink our teeth into.

tmacke17:
I dont understand much why you posted that, my whole post is just that, the code i want done.

You said you had some code, you said it didn't work, I asked what the code was. What is the problem with that?

Oh, I thought you were like saying what code in all, like there wasnt any code to be done... Sorry bout that..

Ill post my code when i get back to my laptop, but ill explain ho i had i t wired:

I didnt actually have my switches yet, so my "switches" are jumpers that connect the pins to ground. That might be where im going wrong, is that right to connect the pin to ground? (I had my code set to use the pull up resistor..)

I had 5 of my "switches" hooked up on a breadboard, and then 3 other pins connected to the RGB of my LED. Then of course ground.
In my code, i had a bunch of if statements in my code, so that if switch1 was connected to ground("LOW") Then red was supposed to come on.

But as soon as i uploaded my code to the board, it just flickered at like 50% on all colors. And then when i would connect a switch to ground, it would make that color, but only with red and blue, no green, and i checked my code. And then the color mixing didnt work at all(The thing where if red and green on, it would output yellow in my code).

So if that clears it up a little, great, but if not, il have my code as soon as possible.

Thanks
Macke

With pull-ups enabled, jumpering the switches to ground is OK.

With the LEDs you need a resistor in series with each one. If not, you are damaging something.

http://www.thebox.myzen.co.uk/Tutorial/LEDs.html

Sorry i left out that part, i do have them there. :slight_smile: