2
$\begingroup$

I've seen lots of examples on how to communicate from Arduino to the computer, but the few that talked about computer to Arduino communications were very hard to understand.

My question is: What code can I use to control my arduino Uno with my keyboard

if it helps, I'm trying to set up a WASD steering behavior.

$\endgroup$
2
  • $\begingroup$ Should we move this question to arduino.stackexchange.com ? $\endgroup$
    – David Cary
    Jan 31 '15 at 21:45
  • $\begingroup$ uhhhh... I asked the same thing there. so if you moved it they might mark as duplicate. you didn't move it within a week so I assumed it wouldn't ever be moved. $\endgroup$ Jan 31 '15 at 21:51
2
$\begingroup$

http://playground.arduino.cc/Main/PS2Keyboard

The extended version http://playground.arduino.cc/Main/PS2KeyboardExt2

This example will show you how to read data from keyboard.The library will let you process keys in real time.From there simple if statement can be used to get the desired effect.I hope that the links will answer any other questions you have.

I hope I have helped but,these question will be better answered in the arduino section vs the robotics section.Comment for any clarification needed.

$\endgroup$
6
  • $\begingroup$ Oh. hah. didn't even see the arduino stack exchange. Thanks for the links. I'll look into them. $\endgroup$ Jan 6 '15 at 0:11
  • $\begingroup$ OK let me know if you need any help in it $\endgroup$ Jan 6 '15 at 0:31
  • $\begingroup$ Yeah. About that. I want to be able to control it with my keyboard, via computer. I'd just use the regular USB plugin. I'm brand new so all I have so far is Serial.begin(9600); $\endgroup$ Jan 6 '15 at 0:49
  • $\begingroup$ take a look at second link.The way they print the arrow can be change to make a motor move instead like byte c=keyboard.read() if(c=='w'){ //move left and right motors foward} $\endgroup$ Jan 6 '15 at 1:33
  • $\begingroup$ +1, does that only work with a certain type of keyboard? $\endgroup$ Jan 6 '15 at 3:48
0
$\begingroup$

This is probably not an answer you are looking for but it helps simplifying the problem. You need first to pick up the right tools to achieve this simple project. First of all, you need a way to detect a keyboard event. In C/C++, there are many APIs for this purpose. For example, GLUT is an old friendly API for this stuff. For this simple project, I recommend using it because it is very simple. After that you need another API for supporting serial communication protocol which allows you to send and receive data from COM port. Windows supports serial communication. If you know C/C++ then this is a piece of cake. Since you didn't mention which language you are using, you might not get a code for your problem.

$\endgroup$
1
  • $\begingroup$ Even simpler than GLUT (and much cleaner, and better designed) is SDL. $\endgroup$
    – Shahbaz
    Jan 27 '15 at 16:13
0
$\begingroup$

I did similar thing using bluetooth module. I connected the bluetooth module to board, for board it was serial1 port, I paired my computer with the bluetooth module and used this library to communicate from PC. https://code.google.com/p/java-simple-serial-connector/.

$\endgroup$

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.