Shop OBEX P1 Docs P2 Docs Learn Events
multiple key-stroke inputs — Parallax Forums

multiple key-stroke inputs

lod7832lod7832 Posts: 6
edited 2007-04-10 21:48 in BASIC Stamp
I am trying to control a robot and I am creating a control box for this to do so and the robot has many tasks that need to be controlled. These tasks require multiply inputs form the key board.· I am trying to figure out ways that will allow me to read in constant values into the basic stamp and be able to know the different values.· For example if I were trying to control motion with the number key pad and trying·to move the robot left.····I would need to hit·an 8 to move forward and then I would need to hit a 4 at the same time to move left. How can I hold down an 8 and 4 to move left and keep this motion as long as I am pushing them down? I am new to the basic stamp and do not know a lot of its abilities.· Please I have been·working on this for quite some time and I do not know what else to do. Thank you for any suggestions ·

Comments

  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-02-21 05:13
    If you are looking at a custom built switch panel - i.e a 4 button unit connected to your device - Have a look at AND gates e.g 7408 - Quad 2-Input and gates ..

    Info on and gates:
    http://www.play-hookey.com/digital/basic_gates.html

    Or are you are looking at sending the directional commands serially from a P.C - to the device

    Quattro

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-02-21 17:07
    Another point:
    if it is a case that this is a purpose built switch unit then Look at the IF, AND options

    ' Looking at a case where 2 buttons are pressed together
    e.g.

    IF IN1 = 1 AND IN2 = 1 Then ....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'
  • lod7832lod7832 Posts: 6
    edited 2007-02-22 00:13
    thanks for the help

    i am trying to read the values in from the serial port one big problem that i am having is i dont konw what type of signal the rs232 is sending and how is it different when it is sending 2 pressed keys.

    does it send a 4 bit signal 8 16? and then how do i take that signal and make it to different variables like in1 and in2 how will keep reading the two values if i am holding them down?

    thank you again
  • QuattroRS4QuattroRS4 Posts: 916
    edited 2007-02-22 02:56
    Are you sending from a specific application on a pc to the serial port (e.g. Hyperterminal ...) ·? Or are you looking to write an application to send to the serial port - to the stamp ?

    If you are sending the information serially you will be 'acting on' what is 'received' therefore the 'IN' example I gave is not relevant. Based on what you have said Read up on the Serin /Serout Commands for serial communications - test communication with Hyperterminal or similar prog.




    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Necessity is the mother of invention'

    Post Edited (QuattroRS4) : 2/22/2007 3:05:33 AM GMT
  • lod7832lod7832 Posts: 6
    edited 2007-04-10 15:10
    i have finally work out what i am doing i am using for now the debug window on the pbasic to send my serial input but i can only get it to read one number at a time if i hit a second key then it becomes the new key entered.· i am trying serin and pulsin comands.· i think that i have to read in a binary number rather than a dec and then try and read the bits that way but i am still not sure how to do that or if that will even work
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2007-04-10 21:48
    Hi lod, one way you can do what you want with debug is to use a small array and capture input into a string array using the STR formatter. The STR formatter can be told the maximum number of values to accept and also which value to use as an end of string character. Here's an example that accepts a maximum 2 values and·uses 13 (which is the ENTER key) to terminate your string if you only want to input 1 value.

    mynumber VAR Byte(2)

    main:
    DEBUGIN STR mynumber\2\13
    DEBUG "ASCII value 1 ", DEC ? mynumber(0),"ASCII value 2 ",DEC ? mynumber(1)
    mynumber(0)=mynumber(0)-48
    mynumber(1)=mynumber(1)-48
    DEBUG "Decimal value 1 ", DEC ? mynumber(0),"Decimal value 2 ",DEC ? mynumber(1)
    mynumber(0)=0
    mynumber(1)=0
    GOTO main

    each element of the array will hold the ASCII value of 1 of your inputs, to convert the ASCII value to·its decimal character value subtract 48. Be aware that the input is stored as two seperate values so entering, for example, 32 is stored as the number 3 in element 0 and the number 2 in element 1. Look at the DEBUGIN and the SERIN help files and formats.

    Jeff T.
Sign In or Register to comment.