//---------------------------------------------------------------------
// header file for revoboard
#include<revobot.h>
void main(void)
{
// setting PORTA as inputs except PA3
TRISA=0b11110111;
// setting PORTB as outputs
TRISB=0b00000000;
// setting PORTD as outputs
TRISC=0b00000000;
// setting PORTC as outputs
// setting PORTD as outputs
TRISD=0b00000000;
// setting PORTE as outputs
TRISE=0b11111111;
// making the buzzer off
buzzer =0;
// initializing adc,pwm modules and making all pins digital
initialize();
// loop to perform light follower
while(1)
{
/*compare the ldr values with threshold setting potentiometers to generate digital output*/
acquire_ldr_digital_values() ;
// if light is detected in front of the bot then move forward
if(rightldr==light && leftldr==light)
{
speedirr(512,cw);
speedirl(512,cw);
}
// if light is detected on the left of the bot
if(rightldr==nolight && leftldr==light)
// then turn to the left to follow the light
{
speedirr(512,cw);
speedirl(512,aw);
}
// if light is detected on the right of the bot
if(rightldr==light && leftldr==nolight)
// then turn to the right
{
speedirr(512,aw);
speedirl(512,cw);
}
// if no light is detected in the vicinity of the bot
// then keep turning till light is detected in the bots vicinity
if(rightldr==nolight && leftldr==nolight)
{
speedirl(512,cw);
speedirr(512,aw);
}
}
}
}
No comments:
Post a Comment
thanks for comment