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 How can I control a 6x5 keypad with Modifiers?
  • 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 Suggested Answer
  • Replies 3 replies
  • Answers 2 answers
  • Subscribers 392 subscribers
  • Views 1367 views
  • Users 0 members are here
Related

How can I control a 6x5 keypad with Modifiers?

james.battie
james.battie over 7 years ago

Hi everyone,

 

I'm asking for some much needed help controlling a 6x5 keypad w/ modifiers (shift key, backspace, space, enter...etc). I have built a circuit that allows use for only one pin on the Arduino Uno. I have all 30 keys responding to key press but I cannot activate the keypad modifiers. I especially need the shift key to function because this keypad has dual sequence key presses (some of the key presses have letters and numbers). I also need to latch the letters and numbers in memory. Can anyone help?

 

My code is as follows:

 

#define KEY_UP_ARROW, 0xDA

#define KEY_DOWN_ARROW, 0xD9

#define KEY_LEFT_SHIFT, 0x81

#define KEY_BACKSPACE, 0x82

#define KEY_SPACE, 0x20

 

#include <Keyboard.h>

 

char* keypressed;

int keyboardPin = A0

int keyboardValue;

int keypressedreleaseALL();

 

void setup(){

     Serial.begin(9600);

     deley (200);

}

 

void loop() {

     keyboardValue = analogRead(A0);

 

     while(keyboardValue<25) {

     keyboardValue = analogRead(A0);

     delay(50);

 

if ((keyboardValue <215) && (keyboardValue >212)) (keypressed = "A"); this is start of code

 

 

 

if((keyboardValue <565) && (keyboardValue >563)) (keypressed = "KEY_LEFT_SHIFT"); end of code

 

     Serial.println (keypressed);

     delay(1000);

 

}

  • Sign in to reply
  • Cancel
Parents
  • 14rhb
    0 14rhb over 7 years ago

    Hi James,

     

    Can you possibly post your circuit diagram to help us provide the right help for you? Is this a circuit you've designed yourself or one that you are copying from an article?

     

    It looks like you are using the analogue input pin of the Arduino and each key press will likely give a different voltage based on an external resistance ladder.

     

    Rod

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • james.battie
    0 james.battie over 7 years ago in reply to 14rhb

    Hey Rod,

     

    I apologize for not responding right away (School, work and life). I really do appreciate your much needed help. I have designed this circuit but I had some helpful ideas from others. What I'm looking for is some help writing a code that will control key press (shift_key). The circuit is below.

    0525.contentimage_187356.jpg5315.contentimage_187357.jpg2744.contentimage_187358.jpg

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • 14rhb
    0 14rhb over 7 years ago in reply to james.battie

    James,

     

    No need to apologise - there is always something that gets in the way of doing electronics ! Thanks for the photos, makes it easier to see what you are doing. I looked around the internet and found this diagram [on Google  ] which is sort of what you are doing I guess. I've had a think about it and share my thoughts below - don't take them to be 100% correct as I've never tried this before ! Hopefully someone on Element14 will have and can also add comment to help you.

     

    image

    I can see how an individual key would change the resistive divider:

     

    'C' button would short x1 to y4 (gnd) and so the divider would be (390R + 390R + 390R divided by 390R + 390R + 390R + 4k7 ). The voltage to the ADC would be ~0.2 * V

     

    '1' button would short x2 to y1 so divider chain would be (390R + 390R + 1k5 + 1k5 + 1k5 divided by 390R + 390R + 1k5 + 1k5 + 1k5 +4k7 ). The voltage to the ADC would be ~0.53 * V

     

    I think while you will be able to use multiple keys anything that uses the same row or column wouldn't have an effect. e.g. Pressing 'C' and '0' would behave as just the 'C'. Pressing '0' and '3' would behave as just pressing the '3'.

     

    If you pressed buttons that were not in the same row or column then you would get some different values e.g. 'C' and '3' would effectively give you 0v at R8 (assuming ADC input impedance is high).

     

    At this point I might go for the empirical approach - try it out and see what values I get and use those in your code as limits. Something like this:

    void loop() {
     
         while(1) {
         keyboardValue = analogRead(A0);
    
         Serial.println(keyboardValue);
         delay(100); 
         }
    }

     

    The issue I would see would be that the shift key would also make your existing single key values incorrect. You will likley have to do a second test on all keys of interest for their values with the shift button held down.

     

    Good luck.

     

    Rod

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • 14rhb
    0 14rhb over 7 years ago in reply to james.battie

    James,

     

    No need to apologise - there is always something that gets in the way of doing electronics ! Thanks for the photos, makes it easier to see what you are doing. I looked around the internet and found this diagram [on Google  ] which is sort of what you are doing I guess. I've had a think about it and share my thoughts below - don't take them to be 100% correct as I've never tried this before ! Hopefully someone on Element14 will have and can also add comment to help you.

     

    image

    I can see how an individual key would change the resistive divider:

     

    'C' button would short x1 to y4 (gnd) and so the divider would be (390R + 390R + 390R divided by 390R + 390R + 390R + 4k7 ). The voltage to the ADC would be ~0.2 * V

     

    '1' button would short x2 to y1 so divider chain would be (390R + 390R + 1k5 + 1k5 + 1k5 divided by 390R + 390R + 1k5 + 1k5 + 1k5 +4k7 ). The voltage to the ADC would be ~0.53 * V

     

    I think while you will be able to use multiple keys anything that uses the same row or column wouldn't have an effect. e.g. Pressing 'C' and '0' would behave as just the 'C'. Pressing '0' and '3' would behave as just pressing the '3'.

     

    If you pressed buttons that were not in the same row or column then you would get some different values e.g. 'C' and '3' would effectively give you 0v at R8 (assuming ADC input impedance is high).

     

    At this point I might go for the empirical approach - try it out and see what values I get and use those in your code as limits. Something like this:

    void loop() {
     
         while(1) {
         keyboardValue = analogRead(A0);
    
         Serial.println(keyboardValue);
         delay(100); 
         }
    }

     

    The issue I would see would be that the shift key would also make your existing single key values incorrect. You will likley have to do a second test on all keys of interest for their values with the shift button held down.

     

    Good luck.

     

    Rod

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
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