Arduino / Windows interfacing?

I’m (very slowly) working on a hardware interface to a software Mp3 player (probably Winamp). Eventually, it’ll be turned into a car PC, but for now, I’m just building a desktop unit. What I want to do is basically use the Arduino to register keypresses & light LED’s to display status. I may also use it to drive an LCD, but it would probably be easier to drive it separately.

What I need to know is how do I make Windows register a button press? The most obvious was would be to just have it emulate a keyboard. Is that possible? If not, do I need some sort of daemon (err… Whatever the windows equivalent is) running on the PC to monitor the USB port? If it is possible to just emulate the keyboard, is there a keyboard command that will allow me to switch to a particular program (and launch it if it’s not open)?

I apologize if this is on the site someplace, but I wasn’t able to locate it.

Thanks!

a simple hardware solution is to use take an existing usb keyboard and take it apart
http://www.potemkin.org/cms/Pid/RepurposingAKeyboard

then use this technique http://www.potemkin.org/cms/Pid/SimulateButton to simulate button presses.

on the macintosh I’ve used my “AppleScript Proxy” to control iTunes from arduino http://www.potemkin.org/cms/Pid/AppleScriptProxy

another technique is to use a media player that has a “slave” interface like mplayer or vlc.
vlc for example can be started as a “daemon” being controlled by simple text based commands given through a socket. this will require a small process that reads the serial port and sends commands to vlc (or mplayer). something like that will be around50 lines of perl or 7 lines of ruby :slight_smile:

other option is to use a small embedded mp3 player that can be controlled from serial commands or simulating keypresses
like the one made by my favourite geek limor fried (MintyMp3 Hardware)
otherwise jelu.se sells an industrial module. you just need an external amplifier and you’re done

massimo

Thanks for your advice. I’ve considered using a keyboard interface, but I’m currently thinking that the Arduino gives me a lot more flexibility. I don’t know what I’ll use that flexibility for, but it seems like a good idea. My current plan is basically like your second suggestion, using a ruby script to sit & monitor the USB port & act as a middleman between the Arduino & whichever mp3 player I end up using. Are there instructions anywhere on how to make ruby talk to the Arduino?

hello

just download and install ruby-serialport-0.6 (or whatever is the latest version)

this code connects to the arduino board and prints whatever character is coming.
the first parametre is the name of the port (COM5 or /dev/cu.usbserial-3B1 or whatever)

#!/usr/bin/ruby

require "serialport.so"


if ARGV.size < 4
  STDERR.print <<EOF
  Usage: ruby #{$0} port bps nbits stopb
EOF
  exit(1)
end


# puts ARGV

sp = SerialPort.new(ARGV[0], ARGV[1].to_i, ARGV[2].to_i, ARGV[3].to_i, SerialPort::NONE)

open("/dev/tty", "r+") { |tty|
  tty.sync = true
  Thread.new {
    while true do
      tty.printf("%c", sp.getc)
    end
  }

}

sp.close

hope this helps

I haven’t done any serial communications programming - can Arduino be controlled through serial port communications?