Shop OBEX P1 Docs P2 Docs Learn Events
Arrow keys to control servos? — Parallax Forums

Arrow keys to control servos?

roughwireroughwire Posts: 78
edited 2008-01-06 20:23 in BASIC Stamp
I am trying to turn two standard servos·from·a·board of ed, BS2. I want to have the servos connected to the board, and the board connected to the computer. Obviously, a person can run a program to turn a servo, but then would have to run another to get the servo(s) to·do something·else; ie, turn differnt direction, or stop. Well what I would like to know, is if there is a way that I could somehow use the arrow keys on my keyboard to turn·the servos [noparse][[/noparse] Up arrow turn servo·#1 counterclockwise, down to turn it clockwise; Left arrow to turn servo #2 counterclockwise, and right to turn it·back clockwise.] Is this possible?
Thank You.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
MIKE

Comments

  • gncguygncguy Posts: 35
    edited 2008-01-04 15:21
    Maybe I do not understand your goal. But couldn't you use the transfer window from the DEBUG window running on the PC to input numerical values or commands
  • gncguygncguy Posts: 35
    edited 2008-01-04 15:21
    Maybe I do not understand your goal. But couldn't you use the transfer window from the DEBUG window running on the PC to input numerical values or commands
  • FranklinFranklin Posts: 4,747
    edited 2008-01-04 17:00
    Mike, yes it's possible. You need to write a program on your PC that listens to the keyboard and when the arrow keys are pressed sends serial data to the stamp. The stamp would then be programmed to change the servos depending on what was sent from the PC.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • roughwireroughwire Posts: 78
    edited 2008-01-05 08:42
    Well, does that mean I would have to use the arrow keys while in the Debug window? If so, that would be just fine. I have tried to find some command that shows how to designate the arrow keys as a specific function, but I can't anything. What commands could I use? Thank you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    MIKE
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-01-05 14:48

    Try·DEBUGIN
  • roughwireroughwire Posts: 78
    edited 2008-01-05 19:45
    Ok, I did find the debugin command. It does seem that a person CAN tell the stamp that a certain number is being pressed. My only question now is if it's possible to tell the stamp to look for arrow keys instead of the numbers. And another thing, I also noticed that when I tried a sample code (Debugin.bs2), it would only take one number per debug, I would need it to constantly change between keys. Thank you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    MIKE
  • Mike GreenMike Green Posts: 23,101
    edited 2008-01-05 19:55
    The PC side of the debug window does some interpretation of the keys pressed. You'd have to write a program in some kind of PC language like Visual Basic that sends serial characters (of your choice) to the Stamp based on the keypresses seen. As far as the Stamp is concerned, it just sees a stream of ordinary serial character codes coming in the programming port.
  • roughwireroughwire Posts: 78
    edited 2008-01-06 17:34
    ok, I have it working, by pressing a number (1-4) which turns the servos, but I still can't figure out how or what to designate the arrow keys. I figure that they have their own ASCII character or something. Or does the debug even read the arrows?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    MIKE
  • FranklinFranklin Posts: 4,747
    edited 2008-01-06 18:37
    You will need to write code ON THE PC SIDE to read the arrow keys and output ascii (anything ascii like l, r, u, d) to the stamp. This is not programmed on the stamp but on the PC.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-01-06 18:43
    The "arrow keys" (the four between the QWERTY and the number pad) aren't associated with ASCII.·

    Alternatively, the number keys on the keyboard's far-right have arrows printed on them (8, up; 6, right; 4, left; 2, down).
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-01-06 20:23
    To expand on PJ's insight a bit: rather than trying to send the actual arrow character sequences, press the NUMLOCK key on your keyboard, and use the "arrow keys" printed on the numeric keypad to output the digits that PJ mentioned.

    -Phil
Sign In or Register to comment.