I'm trying to do something like this.
The problem is that i can't build the loop that does that.
Here is my code:
import parallel
import time
p=parallel.Parallel() #object to use the parallel port
print ("Enter a string of numbers: ")
numStr = raw_input() #read line
numList=list(numSTr) #converts string to list
numlen=len(numList) #the length of the list
numBin=[['1','0001'], ['2','0010'],
['4','0100'], ['5','0101'],
['6','0110'], ['7','0111'],
['8','1000'], ['9','1001'],
['3','0011'], ['0','0000']] #Less significant bits of the numbers from 0 to 9 in a bidimesional array
p.setData(0) #clear the displays
pos=['0001','0010','0100','1000'] #Unique possible positions for the number from 0 to 9.
c=(str(pos[])+str((numBin[][1]))) #here if the number in the list numList exist and also is in numBin. It joins the position and the number in binary, creating an number that will be send in decimal to the parallel port.
p.setData(int(c,2)) #send the binary number in decimal
If someone can help me, that would be gratifying
The most significant bits that are in numBin, define what display to turn on. And the less significant define the number. For example:
The string is {'7', '1', '5', '4', '8'}. So the first number to show in the last display is '7'. SO we take the binary 7 that is '0111' and join that binary string with the first display position that is '0001'. SO we create a binary number: '00010111'. We conver that number to decimal and send it to the parallel port. The parallel port turns on the las display and shows the number 7. The second time, it must show a '7' and a '1' in the second and fist position and so.
X X X X
X X X 7
X X 7 1
X 7 1 5
7 1 5 4
1 5 4 8
5 4 8 X
4 8 X X
8 X X X
X X X X
The 'X' represents that the display is off and the number represents itself in the display position as you can see in the circuit.