Hi. Im currently trying to make a motor run by using the case function for a BB8 project im doing.
I have checked all the parts of the code and made them run separately. But when I put it together it seems that it completely over looks the part of the code that makes the motor run. If anyone could help my out that would be lovely.
[code]
#include <AFMotor.h>
AF_DCMotor motor1(3, MOTOR12_64KHZ);
AF_DCMotor motor2(4, MOTOR12_64KHZ);
char command;
void setup()
{
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
command = Serial.read();
switch (command) {
case 'F':
motor1.setSpeed(200);
motor1.run(BACKWARD);
motor2.setSpeed(200);
motor2.run(FORWARD);
break;
case 'B':
motor1.setSpeed(200);
motor1.run(FORWARD);
motor2.setSpeed(200);
motor2.run(BACKWARD);
break;
case 'L':
motor1.setSpeed(200);
motor1.run(FORWARD);
motor2.setSpeed(100);
motor2.run(FORWARD);
break;
case 'R':
motor1.setSpeed(100);
motor1.run(FORWARD);
motor2.setSpeed(200);
motor2.run(FORWARD);
break;
default:
motor1.setSpeed(0);
motor2.run(RELEASE);
motor2.setSpeed(0);
motor2.run(RELEASE);
break;
}
}
}
[/code]