MuIn USB - How to connect Switches on PortB
by
, 06-12-10 at 20:50 (26255 Views)
If you're going to connect some switches on your MuIn USB (using your firmware), you can consider using PORTB since it has integrated pull-up resistors: one pin of the switch will be connected to GND and other pin on PORTB Input. You'll detect the button pressed with some instructions like those:
if (!LATBbits.LATBx) // x=0...7
{
// instructions to execute if button pressed
}
else
{
// instructions to execute if button not pressed
}
To activate integrated pullup resistors you must include portb.h library in top of your program:
#include <portb.h>
and the activate pullup resistors with dedicate function:
EnablePullups();
Notice tha inputs B0 and B1 are also used by I2C peripheral. If you want use them for switches, you must solder the I2C jumper-pads on the botton of MuIN USB however: solder pad 1 with pad 2 to connect an external pullup resistor on B0 and B1.
If you don't do this, pushing a button on B0 will cause also B1 toggling and vice-versa.