The program works with the wheels turning the way I expect them to. Here is my code:
/*
Evan Johnson
Description: test sending serial input to turn on 1 of 3 leds.
*/
char serInStr[30]; // array that will hold the serial input string
//int breakLed = 2;
//int reverseLed = 4;
void setup()
{
//Setup led for something to monitor working status
//pinMode(led, OUTPUT);
//Setup Channel A
pinMode(12, OUTPUT); //Initiates Motor Channel A pin
pinMode(9, OUTPUT); //Initiates Brake Channel A pin
//Setup Channel B
pinMode(13, OUTPUT); //Initiates Motor Channel A pin
pinMode(8, OUTPUT); //Initiates Brake Channel A pin
//Start the UART TX1/RX0 (D1/D0) communication at defined rate
Serial.begin(115200);
delay(1000);
//Call menu function
menu();
delay(1000);
/*
for(int i=0; i<4; i++)
{
digitalWrite(led, HIGH);
delay(200);
digitalWrite(led, LOW);
delay(200);
}
*/
}
void loop()
{
//read the serial port and create a string out of what you read
if(readSerialString())
{
Serial.println(serInStr);
char cmd = serInStr[0];
int num = atoi(serInStr+1);
if( cmd == 'F' )
{
Serial.println("MADE IT IN F");
//Motor A and Motor B engage breaks
digitalWrite(9, HIGH); // ENGAGE BREAK ON CHANNEL A MOTOR
digitalWrite(8, HIGH); // ENGAGE BREAK ON CHANNEL B MOTOR
//Motor A forward @ half speed
digitalWrite(12, HIGH); //Establish forward direction of channel A
digitalWrite(9, LOW); //Disengage the brake for channel A
analogWrite(3, 255); //Spins the motor on channel A at half speed
//Motor B forward @ half speed
digitalWrite(13, HIGH); //Establishes forward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, 255); //Spins the motor on Channel B at half speed
}
else if( cmd == 'B' )
{
Serial.println("MADE IT IN B");
//Motor A and Motor B engage breaks
digitalWrite(9, HIGH); // ENGAGE BREAK ON CHANNEL A MOTOR
digitalWrite(8, HIGH); // ENGAGE BREAK ON CHANNEL B MOTOR
//Motor A background @ half speed
digitalWrite(12, LOW); //Establish forward direction of channel A
digitalWrite(9, LOW); //Disengage the brake for channel A
analogWrite(3, 255); //Spins the motor on channel A at half speed
//Motor B background @ half speed
digitalWrite(13, LOW); //Establishes forward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, 255); //Spins the motor on Channel B at half speed
}
else if( cmd == 'L' )
{
Serial.println("MADE IT IN L");
//Motor A and Motor B engage breaks
digitalWrite(9, HIGH); // ENGAGE BREAK ON CHANNEL A MOTOR
digitalWrite(8, HIGH); // ENGAGE BREAK ON CHANNEL B MOTOR
//Motor A backward @ half speed
digitalWrite(12, LOW); //Establish backward direction of channel A
digitalWrite(9, LOW); //Disengage the brake for channel A
analogWrite(3, 255); //Spins the motor on channel A at half speed
//Motor B forward @ half speed
digitalWrite(13, HIGH); //Establishes forward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, 255); //Spins the motor on Channel B at half speed
}
else if( cmd == 'R' )
{
Serial.println("MADE IT IN R");
//Motor A and Motor B engage breaks
digitalWrite(9, HIGH); // ENGAGE BREAK ON CHANNEL A MOTOR
digitalWrite(8, HIGH); // ENGAGE BREAK ON CHANNEL B MOTOR
//Motor A forward @ half speed
digitalWrite(12, HIGH); //Establish forward direction of channel A
digitalWrite(9, LOW); //Disengage the brake for channel A
analogWrite(3, 255); //Spins the motor on channel A at half speed
//Motor B backward @ half speed
digitalWrite(13, LOW); //Establishes backward direction of Channel B
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(11, 255); //Spins the motor on Channel B at half speed
}
else if( cmd == 'S' )
{
Serial.println("MADE IT IN S");
//Motor A and Motor B engage breaks
digitalWrite(9, HIGH); // ENGAGE BREAK ON CHANNEL A MOTOR
digitalWrite(8, HIGH); // ENGAGE BREAK ON CHANNEL B MOTOR
}
else
{
Serial.println("Invalid Selection. Please try again!");
return;
}
}
delay(2);
}
//****************************************************
//1) Menu void/void function
void menu()
{
Serial.print("\r\nEvan's Double Gearbox Control!\n"
"'F' for forwards\n"
"'B' for backwards\n"
"'L' for left\n"
"'R' for right\n"
"'S' for stop\n"
"Please enter your command: ");
}
//2) Read a string from the serial and store it in an array
//you must supply the array variable
uint8_t readSerialString()
{
if(!Serial.available())
{
return 0;
}
delay(10); // wait a little for serial data
int i = 0;
while (Serial.available())
{
serInStr[i] = Serial.read(); // FIXME: doesn't check buffer overrun
i++;
}
serInStr[i] = 0; // indicate end of read string
return i; // return number of chars read
}
I only have a multimeter. Nothing is getting too hot. Once the wheels touch the ground it barely moves. You're right I'm probably not getting enough amperage. I hear an amp meter to test. How can I increase amperage?