Guidance on reading from .TXT file

I'm fairly new to Arduino and would greatly appreciate it if someone can point me in the right direction for my project.

I would basically like to control a series of solenoids from numbers on a text file, the text file would be in this format:

1 3 5 6 2 etc

As Arduino reads the text file, I would like it to activate each solenoid accordingly. So for example if it reads a number 1 then it will activate the first solenoid, if its a number 2 then the second solenoid and so on. The numbers only go from 1-6.

To start with I've been using LEDs instead and following the tutorial here:

however it uses processing to read the numbers in real time, i feel like this is an unnecessary step for me as I don't need to update as I go. I would already have all the numbers i need loaded in the text file.

As a bonus if anyone could explain the way in which I could get it to read the first 100 lines of the text file then have it stop until I press a button and continue from where it left off for another 100 lines and repeat this until the end of the file.

Any help here would be greatly appreciated and I hope i have made it as clear as possible! Many thanks in advance


To read a file the file has to be on an SD card. To use an SD card you need to have a shield with one on it. Just look at the SD libary for examples of how to open a file and read it.

As Grumpy_Mike says, to read the file directly it needs to be stored on a device that the Arduino can access.

It's possible to read a text file stored on a PC that the Arduino has a USB connection to but that requires some software on the PC to read the file and send it to the Arduino. Your options for that depend on what OS the PC is running. If it's Windows, you can use Gobetwino to read the file.