View Full Version : serial keypad
02-11-2010, 01: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!
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.
02-11-2010, 03: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
02-11-2010, 03: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.
Parallax Tech Support·
02-12-2010, 12: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:
· SERIN 3, 9600, [Value]
· DEBUG CR, DEC Value
5···· =···· 102
6···· =···· 120
7···· =···· 126
8···· =···· 0 OR 128
0···· =···· 0
*···· =···· 152
#···· =···· 30
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.
02-12-2010, 01: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
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:
02-12-2010, 01:51 AM
Whoopss! Didn't quite understand that whole baud thing before.
It is working wonderfully know! Thanks for you help.
Excellent; just let us know if there is anything else we can help with. http://forums.parallax.com/images/smilies/smile.gif