Line Follower Robo:
Code:
#pragma config OSC = HS
#pragma config OSCS = OFF
#pragma config PWRT = OFF
#pragma config BOR = ON
#pragma config BORV = 45
#pragma config WDT = OFF
#pragma config LVP = OFF
#pragma config DEBUG = OFF
#pragma config STVR = OFF
#define m0 PORTB.F0
#define m1 PORTB.F1
#define m2 PORTB.F2
#define m3 PORTB.F3
#define s1 PORTC.F0
#define s2 PORTC.F1
void main()
{
TRISC= 0xff;
TRISB= 0x00;
while(1)
{
if(s1==1&&s2==1)
{
m0=1;
m1=0;
m2=1;
m3=0;
}
if(s1==1&&s2==0) //rite
{
m0=0;
m1=0;
m2=1;
m3=0;
}
if(s1==0&&s2==1) //left
{
m0=1;
m1=0;
m2=0;
m3=0;
}
if(s1==0&&s2==0)
{
m0=0;
m1=0;
m2=0;
m3=0;
}
}
}
0 comments:
Post a Comment
if you have any doubt please let me know