Show Posts
|
|
Pages: 1 ... 5 6 [7] 8
|
|
92
|
Using Arduino / Project Guidance / Re: using Keypad library for a full QWERTY keyboard
|
on: January 14, 2012, 07:51:32 pm
|
|
option8,
I tried to PM you but the system is down. Hopefully you'll see this post then.
I've made some progress on reading multiple keypresses. There are a couple of things you will need to pay attention to but right now it will read up to 10 simultaneous key presses. Let me if you reply I will post the changes here.
|
|
|
|
|
93
|
Using Arduino / Project Guidance / Re: using Keypad library for a full QWERTY keyboard
|
on: January 12, 2012, 12:23:03 pm
|
I see. I've ordered 2 4*4 keypads and will try them on one arduino with two keypad objects with my keypad library.
Cool. I would appreciate any feedback. I have a feeling that it may take a little while to pin down the problem. Right now I'm working on a solution so option8 can use multiple keypresses without having to load two instances of keypad.
|
|
|
|
|
94
|
Using Arduino / Project Guidance / Re: using Keypad library for a full QWERTY keyboard
|
on: January 11, 2012, 07:44:28 pm
|
Hi liudr, I've been looking at some of your phi code. Nice work. With version 2.0 of the keypad library there is no debouncing during the keyscan. The debounceTime is only used inside the state-machine and runs only after the keyscan is done. Here's the heart of the keyscan code: for( int c=0; c<size.columns; c++) { digitalWrite(columnPins[c], LOW); for( int r=0; r<size.rows; r++) { curKey = digitalRead(rowPins[r]); allKeys += curKey; if(curKey==0) currentKey = keymap[c+(r*size.columns)]; } digitalWrite(columnPins[c], HIGH); }
The variable allKeys provides a status to the state-machine. Oops, almost forgot to answer your implied question. I'm not sure what's happening but I suspect that one of the static variables may be getting shared between the two instances of keypad. I will have to hook up a second keypad and see if I can pin down the problem.
|
|
|
|
|
96
|
Using Arduino / Project Guidance / Re: using Keypad library for a full QWERTY keyboard
|
on: January 11, 2012, 03:05:01 pm
|
Very good, actually. If you are up for it I am using you and your project to improve the library.  Last night I made a couple of changes that will fill an array with every key that is being pressed. Once the array is filled (happens each time the keyboard is scanned) you can first check to see if a modifier was pressed and any other keys after that. There are issues with matrix style keyboards called shadowing and jamming but careful arrangement of the rows and columns will support modifier keys. Unless your keyboard has built in series diodes for each key.(?) That would eliminate those problems.
|
|
|
|
|
97
|
Using Arduino / Project Guidance / Re: using Keypad library for a full QWERTY keyboard
|
on: January 11, 2012, 02:15:23 pm
|
which leads me to think that i'm asking too much of the teensy in each pass of the matrix scan. I don't think the teensy is having any problem handling even this many rows/columns. One reason I say that is because when you swap the getKey()'s the non-working keys work. And a second is because I had to add a bit of code to slow down the scanning of the pins. The teensy is capable of scanning the entire keyboard hundreds, or even thousands of times faster than any human could press a key. would it be more likely to work if i used waitForKey() instead, Not really because getKey() and waitForKey() call the same exact code. Also, waitForKey() blocks which prevents any and all other code from running.
|
|
|
|
|
98
|
Using Arduino / Project Guidance / Re: using Keypad library for a full QWERTY keyboard
|
on: January 11, 2012, 12:40:48 pm
|
What is the keyboard object? Browsed through your code and didn't find a definition. Is it in keypad.h? Just trying to understand your code to see if I can offer any help. Edit: I should have paid closer attention to your question. Sorry about the mis-answer. Yeah, sorry about that, I was using C++ jargon to describe when the 'object' was created in the users code. For example the keypad2 object is created when he called: Keypad keypad2 = Keypad( makeKeymap(keys2), rowPins2, colPins2, ROWS2, COLS2 ); BTW, do you know if the debounce time in the keypad library is static variable or not? Debounce time is variable and can be set by the user, for example: void setup() { Serial.begin(9600); keypad.addEventListener(keypadEvent); keypad.setDebounceTime(500); }
Although, I doubt you'll ever need a debounce time as high as 500 milliseconds. 
|
|
|
|
|
99
|
Using Arduino / Project Guidance / Re: using Keypad library for a full QWERTY keyboard
|
on: January 11, 2012, 12:28:30 pm
|
so i swapped my order of the getKey() lines - now keypad2 is getting updated first. suddenly, my modifiers are working!
but the other keys are all only working intermittently... so i think it's a speed problem. the teensy's not able to update both matrices in one pass of the loop. maybe a delay? No, the keypad was built to work better without any delay()s in your code. I think there might be some interference between the keypad objects keypad and keypad2. I'll take a look and see if I can identify what it might be.
|
|
|
|
|
100
|
Using Arduino / Project Guidance / Re: using Keypad library for a full QWERTY keyboard
|
on: January 11, 2012, 12:25:22 pm
|
using the second keypad object doesn't seem to work. i'm not sure what's happening, though, since even when i explicitly set a modifier key, it has no effect. Thanks for the link to the teensy keyboard code. It was a big help and I can tell you that you are not using the functions to correctly send modifier keys. (Sorry if I sound a bit blunt but I'm racing to post this from work.) I can go into it more when I get home tonight but just a quick example: I see that you commented it out but you used Keyboard.set_key3(MODIFIERKEY_SHIFT); to send a modifier key when you should have used Keyboard.set_modifier(MODIFIERKEY_SHIFT); From the teensy link you also need to do: Keyboard.send_now() After you have set the normal and modifier keys, use Keyboard.send_now() to communicate that combination to the PC or Mac.
|
|
|
|
|
101
|
Using Arduino / Project Guidance / Re: using Keypad library for a full QWERTY keyboard
|
on: January 10, 2012, 11:03:41 pm
|
[thought] i could do it with two keypad objects, the second one only managing the pins for the modifier keys. luckily, they're separated from the alpha/num keys on the keyboard itself. I was thinking the same thing but I haven't been able to test it. I'm not sure just how well a micro can support separate C++ objects in memory. Even if it works there would still be the problem that you could only use one modifier at a time. Control+Shift+<Key> wouldn't be available. Still it would be interesting to see what happens. Are you willing to try?
|
|
|
|
|
102
|
Using Arduino / Project Guidance / Re: using Keypad library for a full QWERTY keyboard
|
on: January 10, 2012, 05:55:57 pm
|
My sketch works in detecting one key at a time, so I can type with it, but it's not very useful without modifier keys. I'm not sure if I'm running into a limitation of the keypad library or if my implementation is lacking. I can tell you with certainty that it's definitely the library. I was one of the people who wrote it.  In fact I made absolutely sure that it would only return one key press at a time. Give me a little time (no later than this weekend) to think about it and I'll see what I can do with the library. Can you tell me what kind of modifiers you'd like to have/use?
|
|
|
|
|
103
|
Using Arduino / Programming Questions / Re: Keypad library - digitalRead() not working
|
on: January 05, 2012, 10:50:58 pm
|
I tried your code unmodified and you are right that things aren't working. But the problem seems to be that you are writing your updates off the end of the lcd. I modified the code to clear and set the lcd to print properly and everything is working perfectly. The only difference is that I left my keypad and lcd connected to my original pins as you'll see in the code below. I used the same pin (52) for the button as you did. If this code doesn't work for you then I will change my pins to match yours and see what happens. #include <LiquidCrystal.h> #include <Keypad.h>
// initialize the library with the numbers of the interface pins //LiquidCrystal lcd(31, 41, 33, 35, 39, 37); LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const byte ROWS = 4; //four rows const byte COLS = 3; //three columns
int buttonState = 0; // current state of the button int lastButtonState = 0; // previous state of the button
char keys[ROWS][COLS] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'} }; //byte rowPins[ROWS] = {22, 32, 30, 26}; //connect to the row pinouts of the keypad byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad //byte colPins[COLS] = {24, 53, 44}; //connect to the column pinouts of the keypad byte colPins[COLS] = {8, 7, 6}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup() { lcd.begin(20, 4); lcd.print("Will the button"); lcd.setCursor(0,1); lcd.print("work?"); delay(1000); Serial.begin(9600); digitalWrite(52,LOW); pinMode(52,INPUT); }
void loop() { char key = keypad.getKey(); if (key) lcd.print(key); buttonState = digitalRead(52); if(buttonState != lastButtonState) if(buttonState == HIGH) { lcd.clear(); lcd.print("SWITCH ON"); } else { lcd.clear(); lcd.print("SWITCH OFF"); } lastButtonState = buttonState; }
|
|
|
|
|
105
|
Using Arduino / Programming Questions / Re: Keypad library - digitalRead() not working
|
on: January 05, 2012, 07:39:09 pm
|
|
Hi CQB_insomnia,
I am one of the authors of the keypad library and you are correct that the library aggressively grabs the pins on every call. But it should be limited to only the pins you designate for use by the keypad. I did that because I wanted to be able to share (multiplex) those pins with the LCD library. I even talked Lady Ada into doing the same thing with the LCD library. When I looked over your code last night I verified that you were not sharing your button with any of the keypad pins and thought that maybe the other answer you were given would fix your problem.
It looks like I will need to test your code, though. I have the mega2560 with the LCD and keypad hooked up and sharing data pins. I used that setup to rewrite getKey() over the Christmas holidays. It's possible I introduced a bug somewhere. Which version of the keypad library are you using? You can find it inside keypad.h or keypad.cpp. I designated the latest version as 2.0
|
|
|
|
|