How to read a .txt file from the pc to the arduino.

Hello! :)

I need to read a .txt file from my pc and use the data with the arduino, is there any function or library that I could be use?

An Arduino cannot read files on a PC. You need a PC program to read the file and send the data to the Arduino.

Have a look at this Python demo. It could easily be extended to do what you want.

...R

hectorjh: I need to read a .txt file from my pc and use the data with the arduino, is there any function or library that I could be use?

You could set up a "webserver" on the PC and put the file in the webservers "HTML root directory". You could use ver simple webserver software on your PC that is easier to configure than IIS or APACHE. Then you can use an "Arduino+Ehternet Shield" as a "web client" to GET the file. The file itself can be of any format, it does not have to be HTML formatted.

Also if you should want to use a Serial connection instead of LAN, you would have to install special software on your PC, that would send a file upon a serial request. If there is a user at the PC, he could use a "terminal software" to send the file. But I don't know what type of software you might use for it, when there is no user at the PC and just the Arduino requests a file, as it was more common 30 years ago than today to use Serial networks.

In general you could use any connection, wireless or wired, to transfer files. But as Robin2 told, you would need a software on the PC which sends the file. Nowadays such sending software is typically a webserver, perhaps.

If LAN is no solution for you, perhaps you could describe more detailed the programming logic and what you want.

search there is code c# doing that to send data from pc to arduino throw usb cable