void switich_1(void)
{
count = 0;
if (modef == 1){ // button is pressed
if (count == 0) {
count++; // increment count
add(); // perform one function
} else if (count == 1) { // on second press
count++; // increment count
subtract(); // perform another function,
} else if (count == 2) { // on second press
count =0;
divide(); //perform another function
}
}
}
As shown in the program above I have just intilialize the count and use it for each
button to press second and third times.
void switich_1(void)
{
count = 0;
if (modef == 1){ // button is pressed
if (count == 0) {
count++; // increment count
add(); // perform one function
modef ==0;
} else if (count == 1) { // on second press
count++; // increment count
subtract(); // perform another function,
modef ==0;
} else if (count == 2) { // on second press
count ==0;
divide(); //perform another function
}
}
}
void switich_1(void)
{
count = 0;
if (modef == 1){ // button is pressed
if (count == 0) {
add(); // perform one function
modef ==0;
delay_msec(100);
count++; // increment count
} else if (count == 1) { // on second press
subtract(); // perform another function,
modef ==0;
delay_msec(100);
count++; // increment count
} else if (count == 2) { // on second press
count ==0;
divide(); //perform another function
}
}
}
void main_loop(void)
{
while (1)
{
/* Panel proccessing */
panel();
/* Watchdog timer reset start */
WDT_Reset();
//**** count ****
dispset_count();
switich_1();
}
I have connected a button to the 8085 microcontrollers and I want that button to perform different functions when pressed again and again.
But now when I pressed it executes all the functions pressing only once.
Code:void switich_1(void) { count = 0; if (modef == 1){ // button is pressed if (count == 0) { count++; // increment count add(); // perform one function } else if (count == 1) { // on second press count++; // increment count subtract(); // perform another function, } else if (count == 2) { // on second press count =0; divide(); //perform another function } } }
void switich_1(void)
{
count = 0;
if (modef == 1){ // button is pressed
if (count == 0) {
count++; // increment count
add(); // perform one function
} else if (count == 1) { // on second press
count++; // increment count
subtract(); // perform another function,
} else if (count == 2) { // on second press
count =0;
divide(); //perform another function
}
}
while(modef==1);
delay(100); // add a 100mSec delay
}
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?