I just received this and started testing. I used an Arduino Fio and just used VCC (3.3v) for all positive voltage to start with and used a sketch I found on the Arduino forum but changed the pins for the Fio. I started testing the A channel and the motor spun fine in one direction but not the other, so I tried changing the PWM values and submitting again a few times. After a few tries, it did not spin at all anymore. I changed the values back to what they had been before, but it still did not spin in either direction. I checked voltages going in and they are fine. I wired the motor directly to VCC and GND and it spins fine. I powered everything off, waited and then back on. It doesn’t work anymore. It isn’t hot or anything; it just seems dead.
It went from working to not working with no changes to how it is wired, but here are pictures of it and code despite that.
white wires in upper right lead to little DC motor.
In preview, it appears to cut off part of the picture so here is the link:
http://i43.photobucket.com/albums/e396/arbarnhart/screen%20shots/TB6612FNG.jpg
Sketch below. Note that the pins for channel B were not connected. I planned to tst them after finishing with A.
//Configure these to fit your design...
//#define out_STBY 9
#define out_B_PWM 3
#define out_A_PWM 9
#define out_A_IN1 10
#define out_A_IN2 11
#define out_B_IN1 5
#define out_B_IN2 6
#define motor_A 0
#define motor_B 1
#define motor_AB 2
void setup()
{
//pinMode(out_STBY,OUTPUT);
pinMode(out_A_PWM,OUTPUT);
pinMode(out_A_IN1,OUTPUT);
pinMode(out_A_IN2,OUTPUT);
pinMode(out_B_PWM,OUTPUT);
pinMode(out_B_IN1,OUTPUT);
pinMode(out_B_IN2,OUTPUT);
// motor_standby(false);
motor_speed2(motor_A,-100);
motor_speed2(motor_B,-100);
delay(2000);
for (int i=-100; i<100; i++) {
motor_speed2(motor_A,i);
motor_speed2(motor_B,i);
delay(50);
}
delay(2000);
// motor_standby(true);
}
void loop()
{
}
void motor_speed2(boolean motor, char speed) { //speed from -100 to 100
byte PWMvalue=0;
PWMvalue = map(abs(speed),0,100,50,255); //anything below 50 is very weak
if (speed > 0)
motor_speed(motor,0,PWMvalue);
else if (speed < 0)
motor_speed(motor,1,PWMvalue);
else {
motor_coast(motor);
}
}
void motor_speed(boolean motor, boolean direction, byte speed) { //speed from 0 to 255
if (motor == motor_A) {
if (direction == 0) {
digitalWrite(out_A_IN1,HIGH);
digitalWrite(out_A_IN2,LOW);
} else {
digitalWrite(out_A_IN1,LOW);
digitalWrite(out_A_IN2,HIGH);
}
analogWrite(out_A_PWM,speed);
} else {
if (direction == 0) {
digitalWrite(out_B_IN1,HIGH);
digitalWrite(out_B_IN2,LOW);
} else {
digitalWrite(out_B_IN1,LOW);
digitalWrite(out_B_IN2,HIGH);
}
analogWrite(out_B_PWM,speed);
}
}
void motor_brake(boolean motor) {
if (motor == motor_A) {
digitalWrite(out_A_IN1,HIGH);
digitalWrite(out_A_IN2,HIGH);
} else {
digitalWrite(out_B_IN1,HIGH);
digitalWrite(out_B_IN2,HIGH);
}
}
void motor_coast(boolean motor) {
if (motor == motor_A) {
digitalWrite(out_A_IN1,LOW);
digitalWrite(out_A_IN2,LOW);
digitalWrite(out_A_PWM,HIGH);
} else {
digitalWrite(out_B_IN1,LOW);
digitalWrite(out_B_IN2,LOW);
digitalWrite(out_B_PWM,HIGH);
}
}