Pages: [1]   Go Down
Author Topic: Simulate a mouse event  (Read 1287 times)
0 Members and 1 Guest are viewing this topic.
Rochefort, France
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
Arduino is a king
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would like to simulate a mouse click to control a video. Is it possible to use a sensor input to the i/o board to create a mouse or a keyboard event?
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 11
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It is possible, but it might not be the easiest method for controlling the video.  What specifically do you need to do?

You can simulate keypresses by taking apart a keyboard (described at http://www.nastypixel.com/instantsoup/?page_id=19) and replacing some of its keys with optocouplers (described at http://www.potemkin.org/cms/Pid/SimulateButton) controlled by the Arduino board.  Something similar should work for a mouse as well.

However, depending on what you need to do, it might be easier to have the Arduino board send commands over the serial port to the computer, where they are read and intepreted by a small program.  For example, if you are (or can) play the video in Flash, then you could simply read the commands via a serial proxy.  If you're on the Mac, you could probably use some AppleScript to read the commands (possibly via a serial proxy) and then send script commands to Quicktime or iTunes, etc.  
Logged

Rochefort, France
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
Arduino is a king
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That's exactly what i want to do: send a command from the board to the computer!
Do you think the serial proxy will do the trick?
On the Arduino site it is said that: "Also useful is the serial proxy for talking to an Arduino board from Flash or other programs." Does it work the other way around: from the Arduino board to Flash?
Logged

Forum Administrator
Offline Offline
God Member
*****
Karma: 52
Posts: 639
I find plain exciting
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hello

serproxy is bidirectional.. you can receive and send data from it.

if your programming language supports serial ports you can talk to arduino directly without using serproxy.

serproxy is useful with platforms like flash that, for security reasons, don't support direct access to serial ports or the disk. serproxy communicates via the network to any program that can open a network connection.

if you tell us a little bit more about what language/platform you are using we can tell you how to do it.

massimo
Logged

Rochefort, France
Offline Offline
Jr. Member
**
Karma: 0
Posts: 73
Arduino is a king
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have an animated sculpture - a robot? - and different Processing clips running on nearby screens as java applets embedded in html files. The idea is to use the sculpture sensors outputs (analogic or digital) to send input to the Arduino board and translate these inputs into Processing functions such as mousePressed, mouseX, mouseMoved, keyPressed, etc...
Thanks a lot for your support!!!!!!
« Last Edit: February 16, 2006, 10:52:58 am by Frogeraie » Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 11
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Check out the Processing Serial library:
http://processing.org/reference/libraries/serial/index.html

You should be able to create a simple protocol for the sensor data, write the data from Arduino over the Serial port, read it in Processing and trigger the right behavior.  

You could try something like this, for example:
A12
B123
A10
C1234
where the first letter of each line is the name of the sensor, and the number that follows gives the value of the sensor.  You can use the Processing function readStringUntil() (http://processing.org/reference/libraries/serial/Serial_readStringUntil_.html) to read a line at a time.
Logged

Pages: [1]   Go Up
Jump to: