Modifications

Sauter à la navigation Sauter à la recherche
Ligne 38 : Ligne 38 :  
This file contains both the base MCP230xx class that makes it easy to use the chip, along with a very simple demo that will toggle a single pin as fast as possible.  The example code shows how you can set pins to both input and output:  
 
This file contains both the base MCP230xx class that makes it easy to use the chip, along with a very simple demo that will toggle a single pin as fast as possible.  The example code shows how you can set pins to both input and output:  
   −
== Instantiating an instance of Adafruit_MCP230xx ==
+
== Créer une instance de Adafruit_MCP230xx ==
To instantiate an instance of the wrapper class that allows you to access the MCP230xx, you need to uncomment one of the two lines at the top of the above code. There are two options because earlier versions of the Pi Model B (pre 512MB SDRAM) used I2C0, whereas the latest Model B devices (with 512MB SDRAM) use I2C1.
+
Pour créer une instance de la classe "wrapper"  qui permet d'accéder au MCP230xx, vous devez retirer le commentaire d'une des deux se trouvant au début du code ci dessous. Il y deux lignes d'initialisation possible parce qu'il y a deux versions du Raspberry Pi. La première version (avant la révision Modèle B et 512MB SDRAM) utilisait la ligne I2C0, tandis que le dernier modèle B (avec 512MB SDRAM) utilise la ligne I2C1.
   −
The address assumes you are using an MCP23017 with all three address pins set to GND.  If you are using a different address pin configuration, you can open up the datasheet to see how the address scheme works ([http://df.mchobby.be/datasheet/MCP23017.pdf fiche technique du MCP23017] ou la [http://df.mchobby.be/datasheet/MCP23007.pdf fiche technique du MCP23008].)
+
C'est la raison de l'existence du premier paramètre '''busnum'''.
 +
 
 +
Le paramètre '''address''' permet d'indiquer l'adresse du MCP23017 en notation hexadécimal assumes you are using an MCP23017 with all three address pins set to GND.  If you are using a different address pin configuration, you can open up the datasheet to see how the address scheme works ([http://df.mchobby.be/datasheet/MCP23017.pdf fiche technique du MCP23017] ou la [http://df.mchobby.be/datasheet/MCP23007.pdf fiche technique du MCP23008].)
    
  <nowiki># Use busnum = 0 for older Raspberry Pi's (pre 512MB)
 
  <nowiki># Use busnum = 0 for older Raspberry Pi's (pre 512MB)
mcp = Adafruit_MCP230XX(busnum = 0, address = 0x20, num_gpios = 16)
+
#mcp = Adafruit_MCP230XX(busnum = 0, address = 0x20, num_gpios = 16)
 
    
 
    
 
# Use busnum = 1 for new Raspberry Pi's (512MB)
 
# Use busnum = 1 for new Raspberry Pi's (512MB)
# mcp = Adafruit_MCP230XX(busnum = 1, address = 0x20, num_gpios = 16)</nowiki>
+
mcp = Adafruit_MCP230XX(busnum = 1, address = 0x20, num_gpios = 16)</nowiki>
    
== Numéro des broches ==
 
== Numéro des broches ==
29 917

modifications

Menu de navigation