element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum wirless display using Arduino and NRF24L01
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 32 replies
  • Answers 2 answers
  • Subscribers 394 subscribers
  • Views 3170 views
  • Users 0 members are here
  • help
  • nrf24l01+
  • led
  • arduino
Related

wirless display using Arduino and NRF24L01

billpenner
billpenner over 11 years ago

I am bogged down in this project

I'm using Arduino UNO.
I Have the keyboard data decoded and printing to the serial port (computer) fine.
I  want to send this data to a 16X2  LCD as soon as it is entered on the keypad.
  The LCD is working fine with serial input from computer to the Arduino but I cannot get the data to display on the
  LCD as soon as  a key is depressed. I have to send “enter”, then all three numbers are displayed.
I must have all three numbers sent to the transmitter as a group but the LCD should display them instantly as they are entered.
When the three numbers have been entered , the "*" key will send the string of numbers to a  NRF24L01.
Another  NRF24L01 and Arduino UNO will decode the data and display the numbers on a large 3 digit, 7 segment display.
The 7 segment display/decoder is working fine.
I can't seem to get the keyboard data into a form suitable for sending to either the 16X2  LCD or the  NRF24L01.
I can't even seem to get it into a string. I guess this is the form I need?
I think the  NRF24L01 will need a string of 3 digit numbers as a string? Right?
This is the code I have so far. Any help in getting me headed in the right direction would be greatly appreciated.
I gone over and over all the examples and tutorials on strings I can find but I can't seem to absorb it enough to make it work.
// key board to remote display.
#include <Keypad.h>
#include <LiquidCrystal.h>
int i;
String  A;                // Setup string to contain the data to transmit.
String  B;
String  C;
String  D;
                                          // set up the keypad decode
const byte ROWS = 4;       // Four rows
const byte COLS = 3;         // Three columns
                                          // Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = { 5, 4, 3, 2 }; // keypad rows to Arduino pins
byte colPins[COLS] = { 6, 7, 8 }; //keypad columns to Arduino pins
                                                    // Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
#define NRF2401                      // output pin to xmitter
void setup()
{
  Serial.begin(9600);
  }
void loop()
{
char key = kpd.getKey();
  delay(10);
  if(key)  // Check for a valid key.
     {
     switch (key)                            // check for transmit or clear keys
    {
      case '*':                                     //send data to transmitter
        Serial.print(key);                      // send data to xmitter
        Serial.println("  pressed");       //testing
      break;
    
                // digitalWrite(transmit); // for testing
                 // break;                          // for testing
      case '#':                                     // clear and reset data
       A,B,C="";                                   // clear strings
        Serial.print(key);    
        Serial.println(" Cleared");         // testing
       // Serial.println(C4);  // for testing
       break;                    
   
      default:    //accum max 3 char
        for(int i=0 ; i<4 ; i++){
         if (i==1)
           A = A + char(key);
           Serial.print (A);            // for testing
           Serial.print (key);        // for testing
         if(i==2)
           B = A +(key);               // for testing
           Serial.print(B);            // for testing
         if(i==3)  
           C = B +(key);
          Serial.println(C);          // for testing
           Serial.print(i);             // for testing
           Serial.print (A);           // for testing
        break;
         // Serial.println(C);         // for testing
       }
     }
     /*    Serial.print (A);
           Serial.print(char(B));                        // For testing
           Serial.print(char(C));
           Serial.print (char(A+B+C+D));
     */
          if(i==4)                                                    //Too many digits! Only three allowed
           Serial.print("   ERROR");
         // Serial.println(i) ;
    }
  }  
  • Sign in to reply
  • Cancel

Top Replies

  • bobcroft
    bobcroft over 10 years ago in reply to Former Member +1
    Hi Averil, Peter has posted some information for you that will help you. However, if you need anything else please send me your email address and I'll forward what I have. I used an Arduino and a LCD display…
  • billpenner
    0 billpenner over 10 years ago in reply to Robert Peter Oakes

    my  code was basically  from  http://tronixstuff.com/tutorials > chapter 42.  I have changed and added sections so that I can

    1. Get a PIN for authority.

    2. Get the message from the keypad.

    3. Send the message wirelessly to another  NRF24 / Arduino for display on a large 7 segment display.

    4. Reset and wait for the next PIN etc.

     

    I have all the sections working individually but cannot seem to go to the  right section based on the results of the previous section.

    In basic I would jump to a subroutine and go back to the main code for the next operation. In this sketch (LCDKeypad) I keep ending up in the wrong place in the code.

    This is probably just my lack of understanding of C++.I have looked over many samples but cannot find code close enough to help me.could you please look over the sketch

    and provide guidance. your previous help is very much appreciated.

     

    //keypad/LCD combo
    // http://tronixstuff.com/tutorials > chapter 42
    #include <Wire.h>
    #include <Keypad.h>
    #include<LiquidCrystal.h>
    //Char Kid();   // need string here  
    LiquidCrystal lcd(27, 26, 25, 24, 23, 22);
    // Create the Keypad
    const byte ROWS = 4; // Four rows
    const byte COLS = 3; // Three columns
    // Define the Keymap
    char keys[ROWS][COLS] =
    {
      {'1', '2', '3'},
      {'4', '5', '6'},
      {'7', '8', '9'},
      {'*', '0', '#'}
    };
    //define Arduino pins & rows
    byte rowPins[ROWS] = {2, 3, 4, 5};
    byte colPins[COLS] = {6, 7, 8};
    //KeyMap
    Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
    //////// AUTHORIZATION CODE ///////
    //     Change Here if  new one is desired  //
    char PIN[4] = {'4', '3', '1','6'}; // our secret (!) number
    char attempt[4] = {'0', '0', '0','0'}; // used for comparison
    int z = 0;
    //*************  SETUP  *******************************
    void setup()
    {
       Serial.begin(9600);
      lcd.begin(16, 2);
      delay(100);
      lcd.clear();
      lcd.print("  Enter PIN...");
      lcd.setCursor(6, 1);
      lcd.cursor();
      lcd.blink();
    }
    //***********  PIN OK  *********************
    void correctPIN() // do this if correct PIN entered
    {
      int(j);
      for ( j = 0;   j < 4 ;  j++ )
      lcd.clear();
      lcd.print(" Enter Kid #");
      Serial.print("I got here");  /////////test///////
      /*
      char key = keypad.getKey();
      //delay(100);
      if (key != NO_KEY)
      {
        lcd.print(key);
        attempt[j] = key;
        j++;
        
        Serial.print("I got here");  /////////test///////
        char(Kid) = key; 
        lcd.print(Kid);
      }
        switch (key)
      {
          case '*':
            z = 0;
            break;
          case '#':
            z = 0;
            
      //lcd.clear();
      //lcd.print("  Enter PIN...");
      lcd.setCursor(6, 1);
       }
      */ 
    }
    //************ incorrect pin entered *******************
    void incorrectPIN() // do this if incorrect PIN entered
    {
      lcd.clear();
      delay(100);
      lcd.print(" * Try Again *");
      delay(2000);
      lcd.clear();
      lcd.print("  Enter PIN...");
      lcd.setCursor(6, 1);
    }
    //************** CHECK PIN ********************************
    void checkPIN()
    {
      int correct = 0;
      int i;
      for ( i = 0;   i < 4 ;  i++ )
      {
        Serial.print(correct);
        
        if (attempt[i] == PIN[i])
        {
        
          correct++;
       
       // Serial.print(PIN);
       //Serial.print(i);
       // Serial.print(i);
        if (correct == 3);
        
         correctPIN();
        }
        else
         incorrectPIN();
      }
     for (int zz = 0; zz < 3; zz++)
      {
        attempt[zz] = '0';
      }
    }
    
    //************** READ KEPAD ********************************
    void readpad()
    {
      char key = keypad.getKey();
      delay(100);
      if (key != NO_KEY)
      {
        lcd.print(key);
        attempt[z] = key;
        z++;
      }
        switch (key)
        {
          case '*':
            z = 0;
            break;
          case '#':
            z = 0;
    
     //  delay(100); // for extra debounce
     //  lcd.clear();
    
       checkPIN();
        break;
       }
     }
    //*************** LOOP **********
    void loop()
    {
      readpad();

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • bozone44
    0 bozone44 over 10 years ago in reply to bobcroft

    Bob:

     

    I just received the 8574 chips i ordered and everything works great.

    Thanks again for the sketch ,the library and you help.

     

    Norm

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
<
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube