#include<p18f452.h>
#include"H:\RECovery RObot\header files\motor.h"
#include"H:\RECovery RObot\header files\delay.h"
#include"H:\RECovery RObot\header files\ladder.h"
#pragma config OSC=HS, OSCS=OFF
#pragma config DEBUG=OFF, LVP=OFF, STVR=OFF
#pragma config WDT=OFF
#pragma config BOR=OFF, PWRT=OFF
#define s1 PORTBbits.RB2
#define s2 PORTBbits.RB3
#define s3 PORTBbits.RB4
#define s4 PORTBbits.RB5
void main()
{
TRISBbits.TRISB2=1;
TRISBbits.TRISB3=1;
TRISBbits.TRISB4=1;
TRISBbits.TRISB5=1;
TRISCbits.TRISC0=0;
TRISCbits.TRISC1=0;
TRISCbits.TRISC2=0;
TRISCbits.TRISC3=0;
TRISCbits.TRISC4=0;
TRISCbits.TRISC5=0;
ADCON1=0X07;
TRISAbits.TRISA0=0;
TRISAbits.TRISA1=0;
while(1)
{
if(s1&s3)
{
ladder_up();
breaks();
delay(200);
}
else if(s4&s3)
{
ladder_down();
breaks();
delay(200);
}
else if(s1&s2)
{
pump_r();
breaks();
delay(200);
}
else if(s4&s2)
{
pump_l();
breaks();
delay(200);
}
else if(s1==1)
{
stop();
rotate_f();
delay(200);
}
else if(s2==1)
{
stop();
rotate_r();
delay(200);
}
else if(s3==1)
{
stop();
rotate_l();
delay(200);
}
else if(s4==1)
{
stop();
rotate_b();
delay(200);//200 ms delay
}
else
{
breaks();
stop();
delay(200);
}
}
}