Hi,
misterT, We do not need to change/add any devices in the circuit. Only with the program that will be burn in the PIC to make works like what I had said before. Thanks anyway
. Here's my updated program. I think it was on my if conditions or functions with goto statement. When I hold 2 buttons, and release 1 it does nothing like what im expecting but when i released the 2nd button it performs its function that supposedly not.
The circuit must only works if only 1 button is pressed and released.
bit oldstate, oldstate1, oldstate2 ;
void main() {
int z = 1, y = 0, x = 1;
TRISD = 0xFF ;
TRISB = 0 ;
PORTB = 0 ;
oldstate = 0;
oldstate1 = 0;
oldstate2 = 0;
A:
do{
if ((oldstate && Button(&PORTD, 1, 1, 1)) || (oldstate1 && Button(&PORTD, 2, 1, 1)) || (oldstate2 && Button(&PORTD, 3, 1, 1)))
{ goto B; }
if (Button(&PORTD, 1, 1, 1)) {
oldstate = 1;
}
if (oldstate && Button(&PORTD, 1, 1, 0)) {
PORTB = x;
y = x;
z = x;
x++;
oldstate = 0;
}
if (Button(&PORTD, 2, 1, 1)) {
oldstate1 = 1;
}
if (oldstate1 && Button(&PORTD, 2, 1, 0)) {
Portb = y*2;
y = y*2;
x = y+1;
z = y;
oldstate1 = 0;
}
if (Button(&PORTD, 3, 1, 1)) {
oldstate2 = 1;
}
if (oldstate2 && Button(&PORTD, 3, 1, 0)) {
Portb = z/2;
z = z/2;
x = z+1;
y = z;
oldstate2 = 0;
}
} while(1);
B: {
PORTB = PORTB;{
if (oldstate && Button(&PORTD, 1, 1, 0)) {
PORTB = PORTB;
oldstate = 0;
}
if (oldstate1 && Button(&PORTD, 2, 1, 0)) {
PORTB = PORTB;
oldstate = 0;
}
if (oldstate2 && Button(&PORTD, 3, 1, 0)) {
PORTB = PORTB;
oldstate = 0; }
} goto A;
}
}