I'm trying to control bidirectional DC Motor (this one:
with arduino. I thought I could do it with 2 NPN transistors, where each one would control specific action (opening or closing the valve) .I would connect the transistors to VIN rail of the arduino and the Digital out terminal. When I would provide voltage with Digital out to the transistor, it would allow voltage (voltage provided by the vin) trough and that would power either opening or closing the valve.
That might sound complicated, so here i provided schema: Login | Tinkercad
(note that schema is missing 9v power supply connected to the arduino)
Now to the problem I'm facing. Both transistors are letting power trough. Both if power is provided with digital out or if i ignore the transitor alltogether in the code:
void setup() {
//pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
//digitalWrite(2, LOW);
delay(1000); // wait for a second
digitalWrite(3, HIGH);
delay(1000); // wait for a second
}
Any tips would me MUCH appreciated, thanks in advance.
LoneWanderer:
I thought I could do it with 2 NPN transistors, where each one would control specific action (opening or closing the valve) .I would connect the transistors to VIN rail of the arduino and the Digital out terminal.
NPN transistors go between the load (solenoid) and GROUND. They don't go between +V and the load. Collector to solenoid, Emitter to Ground. Digital pin through 220-1000 Ohm resistor to Base. Solenoid common to +V.
Can't see the schematic:
Oops! 410 - The requested page has expired
Note: That's not a solenoid valve. It's a bi-directional DC motor. Provide +12V on the Red wire and it opens. Provide +12V on the Blue wire and it closes. The yellow wire is 0V (Ground). That's not something you can do easily with NPN transistors. With a combination of PNP transistors and NPN transistors you could do it.
I wonder if there is protection against powering both Red and Blue at the same time. If not it might short +V to 0V.
I think the easiest solution would be a 12V SPDT or DPDT relay module. Use the double-throw relay contacts in place of the double-throw switch in the wiring diagram.
Your diagram doesn't make sense.
NPN transistors used as high-side switch does not work.
Google "Arduino relay driver" (images), and see how to properly switch a solenoid low-side,
with the emitter of the transistor to ground, and the solenoid between 9volt and collector.
Use a base resistor, and a back-emf diode across the coil.
Leo..
Not intentionally, i tried powering both and it actually has some sort of protection inside of it.. since it didn't blew up in my face. I guess paying extra was worth it.
Now, using switch in my case is not possible. I need Arduino to dynamically open or close the valve based on tempatures I measure with some of my DS18B20's
so the PNP transistors it is.. Oh well, at least the valve is still working
Wawa. That was my plan from the beginning, but then the valve arrived and it had 3 damned cables instead of 2. When I switch (ground and +V) it around, it actually works (to some extend) as the transistor provided with digital signal properly propagates ground through the middle pin. But, that is unfortunately of no use to me.