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.
the direction of the diodes should also be corrected.
Both projects you sent to me had the resistors connected to ground. They need to be connected to VCC or 5V, or whatever voltage the microcontroller is running from.vivian_lys90 said:Hi Doug,
I change the gnd to Vcc already,but the diode 5-8 still cannot display the number of button been pressed. Between, if i want my calliper can measure 3 input and then store and display in the lcd, what should i do?
OPTION_REG.NOT_RBPU = 0; //enable weak pull-ups on PORTB
TRISB = 0xFF; //all PBO-1(8pin) floating high *(set port B as input)*
PORTA &= 0xF0; //set the output value of pins on PEO-1 to 0 these pins are kept as inputs,excepts when one is driven low
//get ready to pull low on PEO-1
//first try pulling each pin of PEO-1 low in succession
for (i = 0; i < 4; i++)
{
TRISA = (TRISA&0xF0) | (~pow2&0x0F); //set PEO-1(4pin) as output so that it can be driven low
//set a single bit as output (forced low)
delay_us(5);
pv = PORTB;
if (pv != 0xFF)
{
for(j = 0; j < 8; j++)
{
if(!(pv & 1))
return i * 8 + j +1;
pv >>= 1;
}
}
}
TRISA |= 0x0F; //all PEO-1 floating high
PORTB = 0; //get ready to pull low on PBO-1
for (j = 0; j < 8; j++)
{
TRISB = ~pow2[j]; //set PBO-1 pins as output so that it can be driven low
delay_us(5);
pv = PORTA;
if (pv & 0x0F !=0x0F) //just checking if one of the PEO-1 pins have been pulled low
{
for(i = 0; i < 4; i++)
{
if(!(pv & 1))
return (i + 4) * 8 + j + 1;
pv >>= 1;
}
}
}