Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
while(1)
{
swnew = portb; // clear mismatch condition
intcon.RBIF = 0; // clear IOC interrupt flag
sleep(); //
nop(); //
/* *
* swnew ____---____-----___ new switch sample *
* swold _____---____-----__ switch state latch *
* delta ____-__-___-____-__ changes, press or release *
* newhi ____-______-_______ filter out new release bits *
* */
delay_us(16); // 16-msec debounce interval
swnew = ~portb; // sample active lo switches
swnew &= 0x0F; // on RB3..RB0 pins
swnew ^= swold; // changes, press or release
swold ^= swnew; // update switch state latch
swnew &= swold; // filter out new release bits
if(swnew.0) // if sw0 (RB0) pressed
{ //
.... //
}
if(swnew.1) // if sw1 (RB1) pressed
{ //
.... //
}
if(swnew.2) // if sw2 (RB2) pressed
{ //
.... //
}
if(swnew.3) // if sw3 (RB3) pressed
{ //
.... //
}
}