Basic Stamp to serial port
Hi i have been working on a project since late december where there are a total of Five buttons.· four of the buttons are used to for characters while the fifth button changes the characters on the 4 buttons.· for example buttons 1 through 4 are A, S, D and F respectively but when you hit the 5th button then the buttons now change to J, K, L and ;.· The problem that i am running into is the part where you connect it to the PC.· in my program i set all the inputs and out puts that i need (4 inputs from the counter and 4 inputs for the buttons) at the beginning then i put:
If (IN0 = 0) AND (IN1 =0) AND (IN2 = 0) AND (IN3 = 0) AND (IN4 = 1) THEN SEROUT 16, 16780, [noparse][[/noparse]65]
Then i do that with the other characters.· the first four inputs come from a counter which sends the outputs in binary(like 0 0 0 0 or 0 0 0 1) and the last one is when i press a button which is connected to input 4.· From what i read that should work but im not getting anything when i connect it to the computer.· i connect to the computer using a D9 pin connecter with pin 2 to SEROUT, pin 3 to SERIN, pin 4 to ATN, pin 5 to ground and pin 6 connected to pin 7. should i have something in my program for SERIN or ATN (which i have no idea how to use since i didnt think you had to) and if so could you help or am i writing the program wrong(should i write it a different way.·
Thanks for your help
MFavs327
If (IN0 = 0) AND (IN1 =0) AND (IN2 = 0) AND (IN3 = 0) AND (IN4 = 1) THEN SEROUT 16, 16780, [noparse][[/noparse]65]
Then i do that with the other characters.· the first four inputs come from a counter which sends the outputs in binary(like 0 0 0 0 or 0 0 0 1) and the last one is when i press a button which is connected to input 4.· From what i read that should work but im not getting anything when i connect it to the computer.· i connect to the computer using a D9 pin connecter with pin 2 to SEROUT, pin 3 to SERIN, pin 4 to ATN, pin 5 to ground and pin 6 connected to pin 7. should i have something in my program for SERIN or ATN (which i have no idea how to use since i didnt think you had to) and if so could you help or am i writing the program wrong(should i write it a different way.·
Thanks for your help
MFavs327
Comments
You can save yourself quite a few instructions if you're always looking at pin ports 0-3 as one entity. Pin ports 0-3 are also know in PBASIC as INA. Thus your statement could be reduced to the following:
'Evaluate Pin ports 0-3 (INA)
IF INA = %0000 THEN Bypass
'Evaluate Pin port 4
IF IN4 = 1 THEN SEROUT 16, 16780, [noparse][[/noparse]65]
Bypass:
That ought to cut back on the "typer's cramp" some·
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Veni, Vidi, Velcro! - I came, I saw, I stuck around!
Post Edited (Bruce Bates) : 1/17/2008 12:18:45 AM GMT
Thanks for your help
Mfavs327
Are you connecting the BS2 I/O pins directly to the PC Serial Port? If so you may have damaged the I/O pins as they would not be able to tolerate the RS-232 voltages present on the PC Serial Port.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Thanks
mfavs327
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
Keys1 DATA "A","B","C","D"
Keys2 DATA "E","F","G","H"
Keys3 DATA "I","J","K","L"
counter=INA
LOOKUP counter,[noparse][[/noparse]Keys1,Keys2,Keys3 etc etc etc......],idx
FOR· address=idx TO (idx+3)
READ address,char(x)······· 'char is a 4 byte array
x=x+1
NEXT
Then use INB as the index for the array
key=INB
index=NCD key
SEROUT 16, 16780, [noparse][[/noparse]char(index-1)]
of course you will have to work on it to get it how you want this is just the general idea.
Jeff T.
·
(an A will show up on the screen).... but when i attached the serial connection ( pin 2 to SEROUT, pin 3 to SERIN, pin 4 to caps and ATN and PIN 5 to ground) and press the button thats attached to the input 4 i get nothing.· Could you tell me what im doing wrong with my code which is shown above or if i need to hook it up differently or write something for SERIN Chris savage?
Thanks
mfavs327
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support