About

csoutreach

Bio:

View complete profile

 

5 thoughts on “About

  1. 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) 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s