arduino - why the output not follow the setcursor? -


why output of function not follow lcd.setcursor position? when type in, output pops out @ different position instead of determined setcursor. need use function multiple times different variables hold different number different purpose. however, need display of numbers on lcd according set position.

here code:

#include <keypad.h> #include <liquidcrystal_i2c.h> liquidcrystal_i2c lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, positive);  // set  lcd i2c address   const byte rows = 4; //four rows const byte cols = 3; //three columns char keys[rows][cols] = {   {'1', '2', '3'},   {'4', '5', '6'},   {'7', '8', '9'},   {'*', '0', '#'} };  byte rowpins[rows] = {9,8,7,6}; //connect row pinouts of keypad byte colpins[cols] = {5,4,3}; //connect column pinouts of keypad  keypad keypad = keypad( makekeymap(keys), rowpins, colpins, rows, cols );   void setup() {   serial.begin(9600);   lcd.begin(20,4);  }   void loop() {         lcd.setcursor(2,0);     int stage1speed = getnumber();     lcd.setcursor(5,0);     lcd.print("sv");      lcd.setcursor(2,1);     int stage1time = getnumber();     lcd.setcursor(5,1);     lcd.print("sec");       lcd.setcursor(2,2);     int stage2speed = getnumber();     lcd.setcursor(5,2);     lcd.print("sec");      lcd.setcursor(2,3);     int stage2time = getnumber();     lcd.setcursor(5,3);     lcd.print("sec");  }   int getnumber() {      static char buffer[4];     static byte = 0;      char key = keypad.getkey();      // < 3: prevent buffer overflow     if  ('0' <= key && key <= '9' && < 3)     {         buffer[i] = key;         ++i;      } else if (key == '#' && > 0)       {         buffer[i] = '\0'; // null-terminate buffer         int value = atoi(buffer);         lcd.print(buffer);         = 0;     } } 


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -