Loading...
Pages: 1 [2]   Go Down
Author Topic: need help to modify this push button code  (Read 536 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

am i correct like this? but why it not goes to state 1. remain at state zero after i push down button.

Code:
/////////////////////////////////////////////////////////////  
  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");
  }
///////////////////////////////////////////////////////////////////////////////
« Last Edit: January 21, 2013, 04:51:06 am by mr_hacker90 » Logged

Roma
Offline Offline
Jr. Member
**
Karma: 0
Posts: 76
Mechmate #70
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks,
Useful lessons for me too !
Logged

East Anglia (UK)
Offline Offline
Edison Member
*
Karma: 48
Posts: 1406
May all of your blinks be without delay
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

(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.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

(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
Logged

NE PA
Offline Offline
Full Member
***
Karma: 5
Posts: 149
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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;
Logged


Offline Offline
Jr. Member
**
Karma: 0
Posts: 96
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: 1 [2]   Go Up
Print
 
Jump to: