PDA

View Full Version : serial keypad



Dan Taylor
02-11-2010, 02:45 AM
Could someone show me an example program for the 4x4 keypad sold by ucontroller.com? I tried a simple SERIN program but a lot of the buttons come back with the same result. Any guidance would be nice!
Thanks!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dan Taylor

JD
02-11-2010, 04:14 AM
Dan,

Can you post the information you have about the module you are using (datasheet and so forth) and the program you are trying to use with it? That way, we can see what all you have and try to offer some suggestions to get you up and running.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,


Joshua Donelson
www.parallax.com (http://www.parallax.com)

Dan Taylor
02-11-2010, 04:21 AM
There is no datasheet that I know of.

But the programs that I have tried have just been something like this:


serin, 5, 9600, [value]
debug ? value

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dan Taylor

dandreae
02-11-2010, 04:22 AM
You can contact Brian at Brian@uController.com (mailto:Brian@uController.com)·for this information.· He maybe able to give the information for·this set up.

Dave

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave Andreae

Parallax Tech Support·

Dan Taylor
02-12-2010, 01:48 AM
This is what Brian told me:


"Is the baud rate set to 9600 ? also sometimes you have the option of inverting, if such an option exists, see if that helps.
The data is returned as an ASCII code,· so you won't receive a "1" when 1 is pressed, you'll instead receive a "49" in decimal, or "31" in hex, whatever number base you are using."


So, Yes my baud rate is set to 9600. He doesn't use the BASIC Stamp so he couldn't write me a program. Here is a program I just ran along with the results:

DO
· SERIN 3, 9600, [Value]
· DEBUG CR, DEC Value
LOOP

Key····· ·Value
1·····=···· 6
2·····=···· 24
3·····=···· 60
4·····=···· 96
5···· =···· 102
6···· =···· 120
7···· =···· 126
8···· =···· 0 OR 128
9···· =·····134
0···· =···· 0
*···· =···· 152
#···· =···· 30
A···· =·····6
B···· =·····24
C···· =···· 30
D···· =···· 96

As you can see some of the buttons return with the same value. Such as the Button 1 and the button A both return with the value 6.
This is the problem I am having.


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dan Taylor

Mike Green
02-12-2010, 02:05 AM
The 2nd parameter to SERIN is not the Baud. It's a number calculated from the Baud and includes some other information as well. The Stamp Editor's help files and the "BASIC Stamp Syntax and Reference Manual" show how to construct this number and gives typical values. Look for the description of the SERIN statement.

Try 84. That's for 9600 Baud, 8 bits, non-inverted.

Post Edited (Mike Green) : 2/11/2010 6:11:59 PM GMT

JD
02-12-2010, 02:14 AM
Dan,

The value for 9600 baud for the BS2 is 84; can you verify you get the same results by replacing the 9600·in the code with 84 and running the program again? This is the command that Mike suggested to review, there is a table in the manual that provides common baud values on page 419.

BASIC Stamp Syntax & Reference Manual:
http://www.parallax.com/Portals/0/Downloads/docs/prod/stamps/web-BSM-v2.2.pdf

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,


Joshua Donelson
www.parallax.com (http://www.parallax.com)

Dan Taylor
02-12-2010, 02:51 AM
Whoopss! Didn't quite understand that whole baud thing before.
It is working wonderfully know! Thanks for you help.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dan Taylor

JD
02-12-2010, 02:51 AM
Excellent; just let us know if there is anything else we can help with. http://forums.parallax.com/images/smilies/smile.gif

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Respectfully,


Joshua Donelson
www.parallax.com (http://www.parallax.com)