I need help with learning how to use my computer to send key presses to my arduino.

I want to make 4 LED's go on and off when the arrow key's are pressed.

The LED's are supposed to be in a X-shape

when you press up, the upper LED is on, and when you release it, it goes off. I have absolutely no idea how to start. thanks in advance
Can you post the code that you're using so far? Also, what arrow keys? Have you interfaced something extra to the board?
My keyboard on my PC, those arrow keys.

And, for the code, i haven't written anything yet, because i dont know what i should do.
This is just for learning purposes, and something to do until get new parts.

I suppose i should make a python program that reads the key presses and sends them to the serial port?
That would be the way to go. Send bytes in a bitmask like this:

%0000abcd

Where a is a 1 is up is pressed, b is a 1 if down is pressed, c is a 1 if left is pressed, and d is a 1 if right is pressed. Then, on the Duemilanove, simply mask out the received value with 1, 2, 4, and 8 to figure out which LEDs to turn on and which to turn off.
Ah, thank you. Now, what should the python code be like? it's been months since i used python Sad
You might want to take a look at pySerial and consult with our resident Python guru for further help.

Here's an example you may want to look at: http://www.makingthings.com/forum/development/141916440
Thanks, I had a book about arduino and robotics from the library, and it explainend some things about using python for communication . Guess ill have to go to the library again after reading these
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement