various codes

line follower :-Code for left wall following
// Code for left wall following
//---------------------------------------------------------------------
// header file for Revoboard
#include<revobot.h>        
void main(void)
{
/
/ Setting PORTA as inputs except PA3 Setting
TRISA=0b11110111;          
// PORTB as outputs
TRISB=0b00000000;          
// Setting PORTC as outputs
TRISC=0b00000000;        
// Setting PORTD as outputs
TRISD=0b00000000;      
// Setting PORTE as outputs
TRISE=0b11111111;      
// Making the buzzer off  
buzzer =0;
/* Initializing adc, pwm modules and setting PA0,PA1,PA2
 AND PA3 pins as analog*/        
initialize();    
// loop to perform wall following with wall on left
while(1)                                                                
{                                                                                                  /* Note :keep the left sensor facing to the left and right sensor  facing the front*/
// if the only left sensor detects no wall
if(leftosensor==nowall )                                                                 {
 // Then move towards wall              
  speedirr(512,cw);                                                      
  speedirl(211,cw);
}
// if the right sensor detects a wall
while( rightosensor==wall )                                    
{
/* Then turn sharply towards the  right to avoid the 90 degree bend in the wall*/
  speedirr(512,aw);                                                    
  speedirl(512,cw);
}
// if the bot drifts towards  the  wall
if(leftosensor==wall )                                                                   {
// then turn away from the  wall
  speedirr(211,cw);                                                      
  speedirl(512,cw);
}
}


}

No comments:

Post a Comment

thanks for comment