I'm trying to control a motorized valve with a foot switch via Arduino, and struggling to get it work. It was working a few days ago, but when I went back to it today I could no longer get the valve to open.
I'm attaching my code and a photo of the breadboard. I can try to draw the circuit if that is more useful. Right now, the LED lights up but the valve does not open which leads me to think this is an issue with the valve part of the circuit. In the photo, the valve is connected to the Arduino VIN- I previously had it attached to a 12 V battery pack and switched it thinking the issue might be with the batteries.
Are there any obvious bad connections or problems I'm missing here? Any ideas for what I can try and troubleshoot? I've also connected the valve to the regulated power supply with no luck. The black wires leading off the board are connected to their component leads with wire joints. The transistor is TIP120. Thanks for any insight!
int pushButton = 2;
int valveControl = 9;
// the setup routine runs once when you press reset:
void setup() {
pinMode(pushButton, INPUT);
pinMode(valveControl, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
if(digitalRead(pushButton) == HIGH){
digitalWrite(valveControl, HIGH);
digitalWrite(LED_BUILTIN, HIGH);
}
else {
digitalWrite(valveControl, LOW);
digitalWrite(LED_BUILTIN, LOW);
}
delay(1);
}
So that 9V smoke alarm battery is powering the Arduino and the valve? Those batteries have low capacity and current output capability. Check the battery voltage with your meter. It is probably near dead. Get a battery that can provide the required current. I would also recommend not powering the valve with the Arduino 5V regulator.
If you want better help, provide a schematic showing all components and power supplies.
The photo is hard to follow.
Kudos for code tags on your first post. Most do not bother to take the time to read the forum guidelines.
groundFungus:
So that 9V smoke alarm battery is powering the Arduino and the valve? Those batteries have low capacity and current output capability. Check the battery voltage with your meter. It is probably near dead. Get a battery that can provide the required current. I would also recommend not powering the valve with the Arduino 5V regulator.
The valve was connected to it's own 12 V power supply. I switched it to the VIN power just to see if there was an issue with the 12V, but it didn't change anything. The 12 V battery pack was connected to the power and ground rails on the right.
The digital input is wired to the wrong side of the pulldown resistor.
The motor current appears to go across the Arduino on the ground pins. Try to only wire to one ground pin on the Arduino. The other grounds may be used for very small loads such as switch pulldowns.
MorganS:
The motor current appears to go across the Arduino on the ground pins. Try to only wire to one ground pin on the Arduino. The other grounds may be used for very small loads such as switch pulldowns.
As another data point, I just connected the valve directly to the battery pack and it worked fine. So I know the switch part of the circuit works (since the LED turns on correctly) and the power works. It seems like the issue is with the transistor but I'm not sure where the specific issue is.