Hello,
I bought one and two cards RaspRack Piface the PiRack is made to add more Piface cards (they are addressable hardware 0-3 by jumpers).
Any record or example, to comment on the software part!
So I installed both cards, the first address in 00, the second address 01.
My question:
– How to send a command to the second Piface card?
– How to read the entries in the second Piface card?
A simple example in Python would be welcome.
Ditto for the interface Piface-emulator, it just recognize the card 00.
Thank you in advance for your answer.
Sincerely Joel.
you need to be using the latest piface software — you can get it on raspbian by doing a sudo apt-get update sudo apt-get install python-pifacedigitalio python3-pifacedigitalio
Addressing multiple PiFaces
Addressing different PiFace boards is simple, you specify the board number, in your read and write commands.
p.digital_write(5, 1, 2) # writes pin5 on board2 high
p.digital_read(2, 3) # reads pin2 (on board3)
Note: As with the PiFace’s pin numbers, the PiFace boards are numbered 0-3.
Example code
The following example code turns each LED/output on four PiFaces on and then off.
You’ll need to indent approriately, this blog doesn’t show the leading spaces.
from time import sleep
import pifacedigitalio as p
p.init()
while(True):
for value in range (0,2):
for board in range (0 , 4): # for use with four boards, reduce this for fewer boards
for pin in range (0,8):
p.digital_write(pin,value==0,board)
sleep(0.02)
Can you implement the function of choosing the card address Piface 0-3 on the test software Piface-emulator?
The latest version of the emulator can select mulitple interfaces on the menu
Hello,
I bought one and two cards RaspRack Piface the PiRack is made to add more Piface cards (they are addressable hardware 0-3 by jumpers).
Any record or example, to comment on the software part!
So I installed both cards, the first address in 00, the second address 01.
My question:
– How to send a command to the second Piface card?
– How to read the entries in the second Piface card?
A simple example in Python would be welcome.
Ditto for the interface Piface-emulator, it just recognize the card 00.
Thank you in advance for your answer.
Sincerely Joel.
Hi,
you need to be using the latest piface software — you can get it on raspbian by doing a sudo apt-get update sudo apt-get install python-pifacedigitalio python3-pifacedigitalio
Addressing multiple PiFaces
Addressing different PiFace boards is simple, you specify the board number, in your read and write commands.
p.digital_write(pin_number, value, board_number)
p.digital_read(pin_number, board_number)
Example commands
p.digital_write(5, 1, 2) # writes pin5 on board2 high
p.digital_read(2, 3) # reads pin2 (on board3)
Note: As with the PiFace’s pin numbers, the PiFace boards are numbered 0-3.
Example code
The following example code turns each LED/output on four PiFaces on and then off.
You’ll need to indent approriately, this blog doesn’t show the leading spaces.
from time import sleep
import pifacedigitalio as p
p.init()
while(True):
for value in range (0,2):
for board in range (0 , 4): # for use with four boards, reduce this for fewer boards
for pin in range (0,8):
p.digital_write(pin,value==0,board)
sleep(0.02)
There’s no need for the zeros in your range() functions, range(4) does the same thing as range(0,4) 🙂