Hello , I have to write a code that read a file in python and convert each chaaravter to 1, or 0 and send these digets to a a selonoid to make a strike or not to make ( brille printing ) is that possible ???? please need your help no time left :( :(

It is certainly possible, though without the details of the hardware we probably can't help you beyond a certain point.

What have you done so far? We cannot and will not do the work for you, though we will try to answer direct questions and give advice towards fixing problems. You need to show that you have made a good faith effort to solve the problem yourself.

We would also need to know what version of Python you are using, as Python 2.x is quite different from Python 3.x and the answers we give may depend on the version at hand.

What I can do is suggest that you start with a with statement, which is the conventional way to open and manage a file in modern Python:

with open("file.txt") as f:
    data = f.readlines()   # get the whole file as a list of strs

This is just one simple example; needless to say, it can be a good deal more elaborate than this.

Edited 2 Years Ago by Schol-R-LEA

The other thing I will recommend is that you consider using a dict (dictionary, or hash table) to look up the translation values that will be sent to the device:

braille_map = {
    'A': [...],
    'B': [...],
    'C': [...],
    # and so on...
    'Z': [...]
}

Where [...] is whatever encoding you need to make.

Untill now I already connect all the hardware (touch screen , 2stepeer motors and the solenoid), and every thing is ok.
but I want to know how to convert each character (I know how to read file ) but how to convert these characters to(zeros and ones)and svae them into a nother file

There are literally thousands of models of stepper motors, solenoids, and touch screens on the market, so that isn't sufficient information for us to help you with. You'll need to check the documentation on the devices in question, or at the very least tell us the make and model of each. It may also help to let us know how you are connecting to the devices (e.g., USB, RS-232 serial, eSATA, HDMI, a proprietary adapter of some kind, etc.).

I doubt anyone here is going to be familiar with the specific hardware, but I may be wrong; if you give us the details we may be able to steer you in the right direction.

Edited 2 Years Ago by Schol-R-LEA

I don't think that it will be necessary to know what model they are...
I just wanna the code of how to read a file from a Flash memory using USB port on raspberry and convert each character to another form and send them to the solenoid ... and I think solenoid model will make no difference !!!!!

Looks like Rabee_1 is talking about a Raspberry Pi computer that uses Python on Linux.
See ...
http://en.wikipedia.org/wiki/Raspberry_Pi

So a Python dictionary that converts each letter to the appropriate zero and one sequence might be the solution.

If I am not mistaken, the Rasberry uses a standard USB Flashcard as disc storage.

Edited 2 Years Ago by vegaseat

I'm not sure about the PI as I've never used it... I'm waiting for the prices to drop a tad more. I've read about reading stuff of an SD card and it seems a lot more involved.

The arduino is perfect, whereas with the raspi as it is effectively just a computer, you have to hack/add how it talks to i/o ports, or at the least it is more involved.

With the arduino, assuming you don't need a fully fledged OS, it does it straight out the box. The programming language is simple and intuitive, you don't even need to have an understanding of electronics to get something to work. Having used it I can testify to this.

How I can connect the ulcd-43pt-pi to raspberry pi and make it display like it display on tv or what ever ??? all the raspbeery contents >>>>
I have already connect it with 4D systems

Why are you asking this in a python forum? This is raspi, head over to the raspi forums, you will get a much better answer.

Failing that, RTFM.

This article has been dead for over six months. Start a new discussion instead.