0

I'm brand new to arduino but I'm trying to figure out how to set up a WASD steering system for my robot I made.

I have the physical setup all ready but I don't know the code to use that would allow me to use my computers keyboard. I would like to still have my keyboard attached to my computer while I do this. I.E. I don't want to manually plug the keyboard into arduino.

I asked this on Robotics stack exchange but they said to ask here.

A list of functions/blocks Iof code that is applicable would be the best answer, but I'll take anything that'll get my bot moving :)

Edit I'm using a wireless keyboard, but my arduino is connected via USB.

  • If you want the keyboard to remain connected to the computer then you need to have the computer tell the Arduino what to do. – Ignacio Vazquez-Abrams Jan 7 '15 at 5:00
  • Which could be as simple as opening a terminal program such as the IDE's serial monitor and having it pass keystrokes down to the arduino. – Chris Stratton Jan 7 '15 at 5:36
  • You did not mention what kind of communication you intend to setup between the comuter and Arduino: serial (USB), WiFi, Bluetooth... All code needed will first depend on that! – jfpoilpret Jan 7 '15 at 5:53
  • @IgnacioVazquez-Abrams Yes that right. how would I do that. like I said, I not fluent with the language yet. I do Python and Basic. – Vince Scalia Jan 7 '15 at 18:03
1

The problem with using the keyboard is the device would have to be tethered to your computer. If you mean for this "robot" to be an explorer, that limits its choices. If it's an arm or something that stays in place, you're fine using the typical serial libraries to monitor your keyboard for input like Chris suggests.

Unfortunately, I don't know of any way to simply plug in the USB keyboard and take in keys. Usually, serial communication is processed between two systems much like two people texting each other. When you see the light blinking on your phone, you know you have a text and how to open it to retrieve the message. In the case of the Arduino, it's checking for a flag bit called RX for the received message and flags a bit for transmitting a message (TX). Each system then pulls down its message and interprets it. In the case of your sketch, you'll be looking for this flag and schedule an action whenever it's checked. Read about Serial communications here and work through the examples to get a feel for it. Because you probably want a real-time response, it might be worth your while to check out interrupts, as well. These are sudden events that get flagged (such as receiving your text) and get handled immediately instead of waiting for the program to refresh and search for the values manually. As a final note, baud rates are the calculated time frames you and your recipient agree on. It would be difficult to receive a full message if you kept cutting off your friend, so it is with computers. This stuff can kind of be tricky at first, but keep at it. Nothing is more ridiculously satisfying than getting that response character from your device.

There's a neat tutorial for getting your Arduino to work through your iPhone here, but it requires an ethernet board, which means a router and wireless board.

Without knowing what you intend to do with it, it's hard to say how to help, but I hope this gets you into it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.