Start by building the robot.
Theory:
It's time to get this robot moving. For that, we need to turn on the servos. With electric motors, you can connect them to a power supply and they will turn one direction. If you want them to turn the other way, you must disconnect the power and switch the wires. For a robot, this would be very difficult, but servos have three wires: positive, ground and control. The positive and ground are the same connections you would use for electric motors. The control wire is what sets servos apart. You can send a signal on the control wire to tell the servo how to move. Most servos are designed to rotate in 180° which is useful if you are using it to control the flaps on an RC plane, but not helpful if you're trying to drive a robot. The servos that came with the robot have been hacked to allow them to rotate continuously. If you tell one of these servos to go to position 45°, it will rotate forward and if your signal tells it to go to 135°, it will rotate backward. They are all set to have 90° be almost stopped (because of minor differences in the servos, they won't all stop at exactly 90°).
Make It Drive:
To get your robot to drive forward, we need to send one servo the signal for 45° and the other to 135°. This is because the servos are pointed in opposite directions. One must turn clockwise to drive the robot forward while the other must turn counter-clockwise. In ArduBlock, start with an empty program block. Grab the Servo block from the DFRobot category and drop it into the loop. Change the pin# to 10 and the angle to 45. Then, grab a second one and set the pin# to 11 and the angle to 135. Upload that and your robot will start moving.
If you look at the code that was generated by ArduBlock, it's done something different. At the top, it says #include <Servo.h>. This tells the Arduino IDE to include the library called Servo.h which allows us to control the servos without having to think about what the signal to them should be. We tell the IDE that we want the servo to go to 45° and the library takes care of translating that for the robot. We also tell the robot that there are servos on pins 10 and 11, then in the loop we tell the robot to drive the servos to their desired locations.
#include <Servo.h>
Servo servo_pin_10;
Servo servo_pin_11;
void setup()
{
servo_pin_10.attach(10);
servo_pin_11.attach(11);
}
void loop()
{
servo_pin_10.write( 45 );
servo_pin_11.write( 135 );
}
This code will make it drive forever. If we want it to drive and stop, we need a little more code.