Download User Manual - Ocean Controls
Transcript
RoboClaw Series
Brushed DC Motor Controllers
RC Control - Arduino Example
The example will drive a 2 motor 4 wheel robot in reverse, stop, forward, left turn and then
right turn. The program was written and tested with a Arduino Uno and P5 connected to S1, P6
connected to S2. Set mode 2 with option 4.
//Basic Micro RoboClaw RC Mode. Control RoboClaw
//with servo pulses from a microcontroller.
//Mode settings: Mode 2 with Option 4.
#include <Servo.h>
Servo myservo1;
Servo myservo2;
int pos = 0;
// create servo object to control a RoboClaw channel
// create servo object to control a RoboClaw channel
// variable to store the servo position
void setup()
{
myservo1.attach(5);
myservo2.attach(6);
}
// attaches the RC signal on pin 5 to the servo object
// attaches the RC signal on pin 6 to the servo object
void loop()
{
myservo1.writeMicroseconds(1500);
myservo2.writeMicroseconds(1500);
delay(2000);
}
//Stop
//Stop
myservo1.writeMicroseconds(1250);
delay(1000);
//full forward
myservo1.writeMicroseconds(1500);
delay(2000);
//stop
myservo1.writeMicroseconds(1750);
delay(1000);
//full reverse
myservo1.writeMicroseconds(1500);
delay(2000);
//Stop
myservo2.writeMicroseconds(1250);
delay(1000);
//full forward
myservo2.writeMicroseconds(1500);
delay(2000);
//Stop
myservo2.writeMicroseconds(1750);
delay(1000);
//full reverse
RoboClaw Series User Manual
26