User manual
52 l Robotics experiment with PIC microcontroller
Listing A3-1 The movement program demonstration of Robo-PICA
2. Drive both motors in opposite direction If the left motor drives forward and
right motor drives backward, the robot will rotate right direction. If its in the opposite
direction, the left motor drives backward and right motor drives forward. The robot will
rotate left direction instead. In this method the speed of rotation will be increase 2 times
and less friction. The turning point is center of robot body. See Figure A3-2.
A3.1 Write program following the Listing A3-1 then compile and download to RBX-877
V2.0 Robot Controller board. Turn-off power switch.
#include <motor.h>
void main()
{
Sound_Init(&PORTC, 0); // Init Sound
while(1)
{
Forward(255); // Call Forward
Delay_ms(2000);
sound_play(100,50); // 1 kHz sound ON RC0
S_Left(255); // Call Spin Left
Delay_ms(800);
sound_play(100,50); // 1 kHz sound ON RC0
Forward(255); // Call Forward
Delay_ms(2000);
sound_play(100,50); // 1 kHz sound ON RC0
S_Right(255); // Call Spin Right
Delay_ms(800);
sound_play(100,50); // 1 kHz sound ON RC0
Forward(255); // Call Forward
Delay_ms(2000);
sound_play(100,50); // 1 kHz sound ON RC0
Backward(255); // Call Backward
Delay_ms(1000);
sound_play(100,50); // 1 kHz sound ON RC0
Motor_Stop; // Stop all
}
}