File IO

Hi,

I am new to the Arduino. Is it possible to read a file from the (computer's) file system? I cannot find the library for that task. Thanks for your help.

Duncan

The short answer is no.

The longer answer is that when the Arduino is connected to a computer, it is a serial device, similar to a mouse, a keyboard, or a printer. You wouldn't expect a mouse to be able to read from the file system, would you?

You can send serial data to an application, in a format that that application understands. If that application understands a command like "Open xxx.log, and tell me what's in it", then, the Arduino could learn about what was in the file. But, not directly. The PC that the Arduino is attached to is not a directly usable peripheral.

There may be other ways to do what you want to do, but we have no idea what it is that you want to do.

Thanks PaulS.

Here is what I plan to do, on the high level:

  1. An app using the web cam to take a picture periodically.

  2. Do some image processing and find where the object is in the picture. Calculate the angle/direction.

  3. Tell the Ardunio to move the servo point to the object.

If that application understands a command like "Open xxx.log, and tell me what's in it", then, the Arduino could learn about what was in the file

I was planning to save the calculation result and let Ardunio to read it. Now it seems the imaging processing app need to send the signal to Arduni. In this case, what will be my best option (serial port, com port, etc) and how do I control the timing of sending and receiving? Thanks again.

Duncan

Look at the Firmata library. It lets you install a sketch on the Arduino that then lets the PC control all the pins on the Arduino. So, once the PC has determined where the object is, it can control the servo directly.

PaulS,

This is the part I am confused. I see the methods

Firmata.sendXXXX()

can help me sending the angle (from image processing) to the pin. But because image processing is done outside this Arduino code, how do I obtain the result? Sorry for cycling back to this question.

Duncan

Probably easier than using Firmata, which hands all control over, would be to have the Arduino check for serial data, using Serial.available and Serial.read, and program it to understand instructions like "Move servo 3 to 35". Other sensors and functions on the Arduino would still work.

http://firmata.org/wiki/Main_Page
:slight_smile:

Thanks everyone's help, and I think I finally got the concept. For anyone who has similar question as I had, this page

http://www.arduino.cc/playground/Main/Interfacing

teaches how to implement an App, by your choice of language, which can "talk" to Arduino board. Arduino on the other hand can just listen the message through serial.read.

You can look into using Gobetwino:

From the page:

Start a program on the PC. Start a program, and wait until it finishes, and tell Arduino it finished.

Send data to any windows program from Arduino, like it was typed on the keyboard.

Send email, optionally with an attached file.

Download a file from the internet.

Read a file and return data to Arduino.

Log data from Arduino to a file, with an optional timestamp.

Periodically check a POP3 mailbox for incoming mails and send commands from the mail to Arduino.

Get the time from the PC.

Get the date from the PC.

Ping a host or IP address.

Copy a file on the PC.