Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
69 lines (61 sloc) 1.49 KB
// Set Motor Control Pins
int rightMotor2 = 13; // D7 - right Motor -
int rightMotor1 = 15; // D8 - right Motor +
int leftMotor2 = 0; // D3 - left Motor -
int leftMotor1 = 2; // D4 - left Motor +
void setup()
{
Serial.begin(115200);
pinMode(leftMotor1, OUTPUT);
pinMode(leftMotor2, OUTPUT);
pinMode(rightMotor1, OUTPUT);
pinMode(rightMotor2, OUTPUT);
digitalWrite(leftMotor1,LOW);
digitalWrite(leftMotor2,LOW);
digitalWrite(rightMotor1,LOW);
digitalWrite(rightMotor2,LOW);
}
void loop()
{
forwardMotor();
}
/* command motor forward */
void forwardMotor(void)
{
digitalWrite(leftMotor1,HIGH);
digitalWrite(leftMotor2,LOW);
digitalWrite(rightMotor1,HIGH);
digitalWrite(rightMotor2,LOW);
}
/* command motor backward */
void reverseMotor(void)
{
digitalWrite(leftMotor1,LOW);
digitalWrite(leftMotor2,HIGH);
digitalWrite(rightMotor1,LOW);
digitalWrite(rightMotor2,HIGH);
}
///* command motor turn left */
void leftMotor(void)
{
digitalWrite(leftMotor1,LOW);
digitalWrite(leftMotor2,HIGH);
digitalWrite(rightMotor1,HIGH);
digitalWrite(rightMotor2,LOW);
}
///* command motor turn right */
void rightMotor(void)
{
digitalWrite(leftMotor1,HIGH);
digitalWrite(leftMotor2,LOW);
digitalWrite(rightMotor1,LOW);
digitalWrite(rightMotor2,HIGH);
}
///* command motor stop */
void stopMotor(void)
{
digitalWrite(leftMotor1,LOW);
digitalWrite(leftMotor2,LOW);
digitalWrite(rightMotor1,LOW);
digitalWrite(rightMotor2,LOW);
}
You can’t perform that action at this time.