I have a sketch that does some weird things. I am able to get it to do what I want on a basic level (3-position switch that turns LED strip 3 different colours) but I am having trouble keeping it stable, the LEDs will turn on for a bit and turn off, randomly. Also the code acts completely differently once unplugged from the USB port and left to the wall power. Here is the code for reference and problem solving. The jist of the code is to have 3 positions (states) one is red, one blue and one is off.
Click on the link in the blue box that says: “click here to start download from sendspace”
It is the actual .ino file I have been working on.
Please help me, and thanks!
EDIT: I have added a circuit diagram ( well to the best of my ability with the software I have) and a direct download for the code.
Once again, I want to be able to have 3 different states that I can switch between for my LED strip. Three different LED patterns. The only stuff that I wrote starts at line 45 and goes to line 79. Everything else is just copied from the LED sketch that I downloaded from the LED site, that code is required for the configuration of the LEDs.
Hi, also a CAD or picture of a hand drawn circuit diagram would also help.
How are you powering your LEDs?
I hope not from the 5V on the arduino board, this is limited in current, and really supplying an array of LEDs is not what it is for.
TomGeorge:
Hi, also a CAD or picture of a hand drawn circuit diagram would also help.
How are you powering your LEDs?
I hope not from the 5V on the arduino board, this is limited in current, and really supplying an array of LEDs is not what it is for.
Tom......
Yeah, I'll get you a circuit diagram this afternoon. And no, I am not powering by the 5V, I am powering it by way of Vin which is supplying 12V from a wall wart.
Are your digitalRead() calls returning the values you expect according to the switch positions? Since the code you posted doesn't tell you, you probably don't know; Serial.print statements to print out the values would let you find out.
PeterH:
Are your digitalRead() calls returning the values you expect according to the switch positions? Since the code you posted doesn't tell you, you probably don't know; Serial.print statements to print out the values would let you find out.
I have added the serial.print and weird things are happening. With the switch connected to GND and a digital pin, when activated it does show what it should but it does not stay as a solid line. There is interference from other digital pins connected to the same GND. I am so confused.
Robin2:
Perhaps it's because I'm thick, but I have no idea what your code is supposed to do.
Why are there huge arrays of identical values? Wouldn't one copy of that value do?
Why are there lines and lines of NOP assembler instructions?
Also there is another file pgmspace.h that seems to have some code in it and you haven't included that.
What does send_1M_pattern() do?
What does send_strip() do?
...R
Ok, so a lot of the code is actually from the LED strip control sketch that I downloaded from the LED strip manufacturer. All I did (well attempting to do) is take the portion of that code that actually sends the final command to the LEDs and link it to a digital pin state. So the "send_1M_pattern()" sends the appropriate section of code from the set of colour combinations. (If you look above there is about 6 different Hexacode type sections that determine the colour of the LEDs.
As for the "send_strip()" portion, once again it is required for the LED strip operation and I just copied the code over. I believe it just tells the Arduino to actually send the pattern over to the LEDs.
It's messy, I am a beginner and I'll also post a link to just the default LED strip control.