Thread: need help storing input values into an array

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2015
    Posts
    40

    need help storing input values into an array

    Hi, I need some urgent help with arrays please, the purpose of the program is to check for a key pressed and store it into an empty array. And then print the entered sequence on the LCD after 'A' is pressed.
    the program compiles but nothing is being stored in the array or printed.
    Once this works, I would like to try and take that stored array and use it as an integer for calculations using the '.' and '-' as math functions(which I am also unclear about)
    I'm sure the solution is really simple fix.
    they are currently no compilation issues.

    Hope someone can help

    Code:
    #include <Keypad.h>
    #include <LiquidCrystal.h> // initialize the library with the numbers of the
    
    
    LiquidCrystal lcd(8, 9, 4, 5, 6, 7); 
    char lonarray[16]; 
    int i;
    
    
    const byte ROWS = 4; //four rows
    const byte COLS = 4; //four columns
    char hexaKeys[ROWS][COLS] = {
    {'1','2','3','A'},
    {'4','5','6','B'}, //define the cymbols on the buttons of the keypads
    {'7','8','9','C'},
    {'.','0','-','D'}
    };
    byte rowPins[ROWS] = {13, 12, 11, 10}; //connect to the row pinouts of the keypad
    byte colPins[COLS] = {33, 32, 31, 30}; //connect to the column pinouts of the keypad
    
    
    
    
    Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS); //initialize an instance of class NewKeypad
    
    
    void setup()
    {
    lcd.begin(16, 2);
    Serial.begin(9600);
    }
    
    
    void loop()
    {
    char customKey = customKeypad.getKey();
    
    
    if (customKey == '0'){ lonarray[i] == '0'; i++;}
    if (customKey == '1'){ lonarray[i] == '1'; i++;}
    if (customKey == '2'){ lonarray[i] == '2'; i++;}
    if (customKey == '3'){ lonarray[i] == '3'; i++;}
    if (customKey == '4'){ lonarray[i] == '4'; i++;}
    if (customKey == '5'){ lonarray[i] == '5'; i++;}
    if (customKey == '6'){ lonarray[i] == '6'; i++;}
    if (customKey == '7'){ lonarray[i] == '7'; i++;}
    if (customKey == '8'){ lonarray[i] == '8'; i++;}
    if (customKey == '9'){ lonarray[i] == '9'; i++;}
    if (customKey == '.'){ lonarray[i] == '.'; i++;}
    if (customKey == '-'){ lonarray[i] == '-'; i++;}
    if (customKey == 'A')
      {
        //lcd.clear;  
        lcd.print("nmbrs prsd were:");
        lcd.setCursor(0,1);
        lcd.print(lonarray);
        
      }
    delay(250);
    Serial.print(customKey);
    }
    Last edited by DA93; 02-09-2016 at 04:10 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Storing input values into Array
    By nelly26 in forum C Programming
    Replies: 1
    Last Post: 11-30-2011, 09:42 AM
  2. Storing values in an array
    By kpop in forum C Programming
    Replies: 3
    Last Post: 04-12-2011, 01:46 PM
  3. Storing values into a dynamic array
    By porsche911nfs in forum C++ Programming
    Replies: 5
    Last Post: 04-24-2009, 09:08 AM
  4. Storing input values while iterating
    By russel1013 in forum C Programming
    Replies: 11
    Last Post: 07-29-2008, 08:32 AM
  5. Storing values from Edit Box into an array
    By E_I_S in forum C++ Programming
    Replies: 10
    Last Post: 06-05-2008, 06:24 AM

Tags for this Thread