/*
Processor-PIC16f628A Clock-4MHz
Motors=5
*/
sbit ILED at RA1_bit;
sbit IW at RA2_bit;
sbit OverB at RA3_bit;
sbit OverS at RA4_bit;
sbit ILowS at RA5_bit;
sbit ILowB at RB0_bit;
sbit OLow at RB1_bit;
sbit OHigh at RB2_bit;
sbit IMB1 at RB3_bit;
sbit IMB2 at RB4_bit;
sbit IMS at RB5_bit;
sbit BM at RB6_bit;
sbit SM at RB7_bit;
unsigned short counter;
void interrupt()
{
if(INTCON.T0IF){
counter++;
if(counter==18)
{
if(IW==1)
{
ILED=1;
IMB1=1;
IMB2=1;
IMS=1;
}
else if(IW==0)
{
ILED=0;
IMB1=0;
IMB2=0;
IMS=0;
}
counter=0;
}
}
INTCON.T0IF=0;
}
void main()
{
CMCON = 0x07; // To turn off comparators
TRISA = 0b00111100;
TRISB = 0b00000111;
OPTION_REG=0x87;
INTCON=0b10100000;
do{
if(OverB==1)
{
IMB1=0;
IMB2=0;
}
if(OverS==1)
{
IMS=0;
}
if(ILowS==0)SM=0;
if(ILowB==0)BM=0;
if(OLow==1)
{
if(ILowS==1)
{
SM=1;
}
if(ILowB==1)
{
BM=1;
}
}
if(OHigh==1)
{
BM=0;
SM=0;
}
}while(1);
}