#include <16F877.h>
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#fuses HS,NOPROTECT,NOWDT,BROWNOUT,PUT,NOLVP
#define motor2 PIN_E0 //MOTOR 1
#define motor1 PIN_E1 //MOTOR 2
#define enable1 PIN_c1// enb 1
#define enable2 PIN_c2 //enb 2
main()
{
while(1)
{
if(!input(PIN_E0)&&(!input(PIN_E1)))
{
output_high(enable1);
output_high(motor1);
output_high(enable2);
output_high(motor2);
delay_ms(1000);
}
else if(input(PIN_E0)&&(!input(PIN_E1)))
{
output_high(enable1);
output_high(motor1);
output_low(enable2);
output_high(motor2);
delay_ms(1000);
}
else if(!input(PIN_E0)&&(input(PIN_E1)))
{
output_low(enable1);
output_high(motor1);
output_high(enable2);
output_high(motor2);
delay_ms(1000);
}
else
{
output_high(enable2);
output_low(motor2);
output_high(enable1);
output_low(motor1);
delay_ms(1000);
}
}
Friday, November 2, 2007
Main component for making a robot
Basically, the robot needs a micro controller to control the robot.For this robot, it used PIC 16F877A as a controller.It also used driver motor L293B to control motor forward and reverse.Beside that, micro beam sensor was used to sense the obstacle and give the input to PIC16877A. The controller should be program by C language into PIC.
Subscribe to:
Posts (Atom)