// 21 july 2011
// program to Test button 1 and 2 on portA for a high or low
sbit button1 at ra0_bit; // assign ra0 to button 1
sbit button2 at ra1_bit;
int time ; // global variable
void main(void)
{
// Program entry point.
TRISA0_bit = 1; // set porta pin0 as input.
TRISA1_bit = 1;
TRISB = 0; // set portb pins as output.
PORTB = 0; // set portb pins to low.
time = 250 ;
do{
if (button1 == 1 ){ // if button1 is pressed, execute
time +=10; // the following statement.
PORTB = 0b0000010; // turn on rb1 if button 1 is pressed ra0
delay_ms(time) ;
PORTB = 0b0000000; // turn off rb1
delay_ms(time);
}
if(button2 == 1){ // if button1 is pressed, execute
time -=10; // the following statement.
RB1_bit = 1; //PORTB = 0b0000010; // turn on rb1 if button 1 is pressed ra0
delay_ms(time);
RB1_bit=0; //PORTB = 0b0000000; // turn off rb1
delay_ms(time);
}
}while (1);
}