≡ Menu

Batty Bot

 

Servo (motor) control

Here is some sample code to move a servo. Since the robot uses servos for the motors, we use this code to control it to make it go forward , backwards or turn. The servos are attached to the robot with one facing forwards and one backwards so. You have to set one motor forwards (10) and the other backwards (170).

#include <Servo.h> 

Servo myservo;

void setup() 
{ 
  myservo.attach(9);
  myservo.write(90);  // set servo to mid-point
} 

void loop() {}