Go Down

Topic: need help to modify this push button code (Read 1 time) previous topic - next topic

mr_hacker90

#15
Jan 21, 2013, 10:46 am Last Edit: Jan 21, 2013, 10:51 am by mr_hacker90 Reason: 1
am i correct like this? but why it not goes to state 1. remain at state zero after i push down button.

Code: [Select]

/////////////////////////////////////////////////////////////  
 if (currentState == 0 && buttonPressed == DOWN_BUTTON_MENU)
 {
   (currentState == 1);
   lcd.clear();
   lcd.setCursor(0,0);                       // set lcd.setCursor (column,row)
   lcd.print("Add Fingerprint");
 }
 
 else if (currentState == 1 && buttonPressed == DOWN_BUTTON_MENU)
 {
   (currentState == 2);
   lcd.clear();
   lcd.setCursor(0,0);                       // set lcd.setCursor (column,row)
   lcd.print("Delete");
   lcd.setCursor(0,1);                       // set lcd.setCursor (column,row)
   lcd.print("Fingerprint");
 }
 
 else if (currentState == 2 && buttonPressed == DOWN_BUTTON_MENU)
 {
   (currentState == 3);
   lcd.clear();
   lcd.setCursor(0,0);                       // set lcd.setCursor (column,row)
   lcd.print("Search");
   lcd.setCursor(0,1);                       // set lcd.setCursor (column,row)
   lcd.print("Fingerprint");
 }
 
 else if (currentState == 3 && buttonPressed == DOWN_BUTTON_MENU)
 {
   (currentState == 4);
   lcd.clear();
   lcd.setCursor(0,0);                       // set lcd.setCursor (column,row)
   lcd.print("Empty Database");
 }
 
 else if (currentState == 4 && buttonPressed == DOWN_BUTTON_MENU)
 {
   //(currentState == 0);
   lcd.clear();
   lcd.setCursor(0,0);                       // set lcd.setCursor (column,row)
   lcd.print("Search Database");
 }
///////////////////////////////////////////////////////////////////////////////

Silverdog63


UKHeliBob

(currentState == 1); does nothing.  Actually not quite true, but not what you want
currentState = 1; sets the currentState variable to 1

== compares 2 things
= sets the variable on the left to the value on the right.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

mr_hacker90


(currentState == 1); does nothing.  Actually not quite true, but not what you want
currentState = 1; sets the currentState variable to 1

== compares 2 things
= sets the variable on the left to the value on the right.


actually not quite true? i think my coding is like this. my initial state is zero by the way. currentState = 0; sets the currentState variable to 1

Quick5pnt0

In your code you have: (currentState == 1);

That won't do as you are intending. Assuming you want currentState to change to 1 you need to change it to: currentState = 1;

mr_hacker90


In your code you have: (currentState == 1);

That won't do as you are intending. Assuming you want currentState to change to 1 you need to change it to: currentState = 1;


haha. thank you for that. now it is working. thanks buddy.

Go Up