make your own h-bridge
One of the finals I'm working on requires using an h-bridge to drive a motor (if you don't want to spend $$ on a motor controller). I pretty much followed the example on this site. Because I only had NPN transistors, I had to modify the circuit so that Q3 was linked to A and Q4 was linked to B. Also, I needed to add in diodes for the digital input pins or else the microprocessor would get reset from time to time. Tested this with a low-power motor. Works like a charm =)
Follow extended text for test code...
#define PIN_A 2
#define PIN_B 3
void setup () {
pinMode(PIN_A,OUTPUT);
pinMode(PIN_B,OUTPUT);
Serial.begin(9600);
}
void write_a () {
digitalWrite(PIN_A,HIGH);
digitalWrite(PIN_B,LOW);
}
void write_b () {
digitalWrite(PIN_A,LOW);
digitalWrite(PIN_B,HIGH);
}
void loop() {
write_a();
delay(1000);
write_b();
delay(1000);
}