Help with LED programming.

I want to power a 7 color blinking LED from RadioShack (http://www.radioshack.com/product/index.jsp?productId=3060680) I want the power to the LED to be constant so it stays on. I will have the ground pin connected to ground. I want the switch pin to be hooked up to a pin that I can have it go LOW or have it go to ground, and then have it delay I guess, and then have it go to LOW again so it changes colour. Please help me out. I am very new at C programming and I haven't found anything on Google.

Much appreciated.

Have you got any data on the device? Part number? Manufacturer?

Well, I am getting an Arduino Duemilanove in about 2 days, and I want to write some code for it so I don't have to wait to do anything. I already wrote a rather long police light sketch that has different light patterns using just the LED's and the "delay", "HIGH" and "LOW" commands. I just need to know how to set pin 13 or whatever pin as HIGH without it interfering with the code at all because it will mess up my whole thing.

I just wrote this (which I doubt will work how I want):

void setup() { pinMode(13, OUTPUT); //The pin I want constant on/HIGH. pinMode(12, OUTPUT); //Constant ground/LOW. pinMode(11, OUTPUT); //Pin I want to be able to switch between ground and off. } void loop() { digitalWrite(13, HIGH); //The pin I want constant on/HIGH. digitalWrite(12, LOW); digitalWrite(12, LOW); delay(3000); }

If you've worked with the LED I put in the link in my original post you will know what I'm talking about. Slightly unrelated: how many LED's can I power using one pin as Vcc+(doesn't have to be a specific pin)?

Once a pin is written HIGH, unless you do something very wrong, it will stay HIGH. What makes you think it will mess things up?

Okay well I want that pin to stay HIGH while I change a different pin to go from LOW to off if that's possible. How could I do that?

void setup() { pinMode(13, OUTPUT) pinMode(12, OUTPUT) pinMode(11, OUTPUT) } void loop() { digitalWrite(13, HIGH); [u]//Will this stay HIGH if I change the value of pin 11?[/u] digitalWrite(12, LOW); //I need this as constant ground, or I can use the actual constant ground on my board. digitalWrite(11, LOW); //I need this pin to change from LOW to off if possible. This will be a ground pin delay(3000); }

Could I do this?

void setup() { pinMode(13, OUTPUT); pinMode(12, OUTPUT); pinMode(11, OUTPUT); } void loop() { digitalWrite(13, HIGH); digitalWrite(12, LOW); digitalWrite(11, LOW); pinMode (11, delay(3000)); //I don't think this will work. }

pinMode (11, delay(3000)); //I don't think this will work

Did you even try compiling it?

digitalWrite(13, HIGH); //Will this stay HIGH if I change the value of pin 11?

See reply #3

Instead of asking if it'll work I will just compile it. It of course didn't work.

Error: BareMinimum.cpp: In function 'void loop()': BareMinimum:14: error: invalid use of void expression

I really need help figuring out how to make one pin HIGH or LOW. Can you help or not? I tried Google, I found nothing.

pinMode (11, delay(3000));

This suggests a confusion about what "pinMode" does (it sets a pin to be either an input or an output) and what "delay" returns (nothing) and why you would want to set a pin's mode based on the (non-existant) return value of a delay.

Well as I stated earlier, I want the Arduino to automatically change the color's of a 7 color LED. The LED is connected to power with the anode, and ground with the cathode. There is a third pin that if momentarily connected to ground it will change the color of the LED.


| | | ___ | / |+V |_ -V | | | | | | | | | Switch ^ ^ ^ Vcc+ ^ Ground

I need constant power to the middle pin, constant ground to the pin on the far right, and momentary ground with delay to the pin on the far left.

http://www.seanliming.com/Docs/Articles/MSGBB557TA_7_Color_LED.pdf The link is of a lot of use for anyone trying to help.