hello,
i just learned fritzing so here is a poor attempt to show you the circuit i am working with. i hope you get the idea:
http://www.jeremycouillard.com/circuit.jpg (it's actually an atmega 328p but the pin config is the same)
the relays are not the ones i have but they are an spst relay that is turning the motors on and off and a dpdt relay that is reversing the polarity. the spst is 5v, powered by the arduino with a nominal current of 20mA. there is a diode across the coils. the dpdt is 12v and controlled through a tip120 transistor (with a diode). everything is powered through a 12v 1.7amp wall wort.
the leds are 12v, huge things and also are being powered separately and controlled through tip120s. the leds have a forward voltage of 3.5.
the code, pasted below, is very very simple. just starts the motors in one polarity, stops them, blinks some lights, then starts them again in a different polarity.
The problem is as follows: The program starts up and everything runs fine for about 2-3 cycles and then it either 1) just stops or 2) the relays and lights start turning on and off in a continuous loop...about 2 seconds on, two off. it is very strange....i've never had a circuit do something that wasn't in the code. Is there anything in my circuit that is suspect? any help/guidance would be so so appreciated!!!
void setup() {
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(5, OUTPUT);
digitalWrite(13, LOW);
digitalWrite(13,LOW);
delay(5500);
}
void loop() {
digitalWrite(13, HIGH);
digitalWrite(12, HIGH);
delay(35000);
digitalWrite(13, LOW);
digitalWrite(12, LOW);
//light show needs to be 11 seconds exactly
//22 loops
////////////////////////////////////////////////
for (int i = 0; i<22;i++){
digitalWrite (11, HIGH);
delay(100);
digitalWrite(10, HIGH);
delay(100);
digitalWrite(5, HIGH);
delay(100);
digitalWrite(11, LOW);
delay(100);
digitalWrite(10, LOW);
delay(100);
digitalWrite(5, LOW);
}
///////////////////////////////////////////////
//delay(11000);
digitalWrite(13, LOW);
digitalWrite(12, HIGH);
delay(36000);
digitalWrite(13,LOW);
digitalWrite(12,LOW);
delay(2000);
}