atari controller
froslie
Posts: 67
Help a novice please - sometimes easy things just miss me.
Anyway, I have built what I believe will be a functioning circuit to link an atari controller to A BS2.
The problem is the code.· I understand how to set the pins on the STAMP to HIGh or LOW - easy enough. I do not understand for this project how I can read the pin to see HIGH or LOW.·
The controller is basically a series of five buttons. They are normally HIGH until the joystick forces them to LOW. If I can read the button to see it go·LOW -·with an IF statement or something I will be set.
Any suggestions?
Anyway, I have built what I believe will be a functioning circuit to link an atari controller to A BS2.
The problem is the code.· I understand how to set the pins on the STAMP to HIGh or LOW - easy enough. I do not understand for this project how I can read the pin to see HIGH or LOW.·
The controller is basically a series of five buttons. They are normally HIGH until the joystick forces them to LOW. If I can read the button to see it go·LOW -·with an IF statement or something I will be set.
Any suggestions?
Comments
Both the PBASIC Stamp Manual (free for the download) and the PBASIC Help file are quite clear on the use of the IF statement, so I'm not sure where you're having a problem. Here is the start of some simple switch checking code:
' {$PBASIC 2.5}
' Assign Pin ports 0-4 to Switches 0-4
Sw0 PIN 0 : Sw1 PIN 1 : Sw2 PIN 2 : Sw3 PIN 3 : Sw4 PIN 4
' Set all Pin ports to INPUT mode
Input Sw0 : Input Sw1 : Input Sw2 ; Input Sw3 : Input Sw4
Begin: 'Presume multiple keys can be pressed
'Check each switch to see if it's LOW (0)
IF Sw0 = 0 GOSUB Process_Sw0
IF Sw1 = 0 GOSUB Process_Sw1
IF Sw2 = 0 GOSUB Process_Sw2
IF Sw3 = 0 GOSUB Process_Sw3
IF Sw4 = 0 GOSUB Process_Sw4
GOTO Begin
Process_Sw0:
.....
RETURN
Process_Sw1:
.....
RETURN
END
etc.
Regards,
Bruce Bates
I do understand the IF statement - I meant to mention it simply as an example of my limited experience using the Stamp.
I have not used switches. The code looks great and I believe this should start me out in excellent condition.
Very much appreciation for the help.
Pete Froslie
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
And yes, you'll use an IF statement, and you also may need some debouncing. I wouldn't use the BUTTON statement myself, as you'll probably want to read the positions of all the switches at the same time.
·· My recommendation would be to tie the lines to a port on the BASIC Stamp and read the entire port at once.· It would be easy to catch diagonal movement (2 switches pressed at once).· You could do an INA for example, then read the bits.· You would also be able to read the fire button pressed at the same time as movement.· You would need the pullup resistors though.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax