Différences entre versions de « MCP23017-Brancher-Sortie »
(Page créée avec « {{MCP23017-NAV}} {{traduction}} {{MCP23017-TRAILER}} ») |
|||
Ligne 2 : | Ligne 2 : | ||
{{traduction}} | {{traduction}} | ||
+ | |||
+ | == Code == | ||
+ | Voici le code issu du programme toggle.pde de la librairie [https://github.com/adafruit/Adafruit-MCP23017-Arduino-Library/blob/master/examples/toggle/toggle.pde Adafruit-MCP23017-Arduino-Library]. | ||
+ | |||
+ | <nowiki> | ||
+ | /* Exemple toggle.pde | ||
+ | Utilise la librairie Adafruit-MCP23017 pour changer une sortie du MCP23017. | ||
+ | |||
+ | Code écrit par LadyAda pour AdaFruit Industries [www.adafruit.com] | ||
+ | |||
+ | TRADUCTION FRANCAISE par Meurisse D. pour MCHobby.be [www.mchobby.be], CC-BY-SA pour traduction | ||
+ | TUTORIEL | ||
+ | |||
+ | #include <Wire.h> | ||
+ | #include "Adafruit_MCP23017.h" | ||
+ | |||
+ | // Basic pin reading and pullup test for the MCP23017 I/O expander | ||
+ | // public domain! | ||
+ | |||
+ | // Connect pin #12 of the expander to Analog 5 (i2c clock) | ||
+ | // Connect pin #13 of the expander to Analog 4 (i2c data) | ||
+ | // Connect pins #15, 16 and 17 of the expander to ground (address selection) | ||
+ | // Connect pin #9 of the expander to 5V (power) | ||
+ | // Connect pin #10 of the expander to ground (common ground) | ||
+ | |||
+ | // Output #0 is on pin 21 so connect an LED or whatever from that to ground | ||
+ | |||
+ | Adafruit_MCP23017 mcp; | ||
+ | |||
+ | void setup() { | ||
+ | mcp.begin(); // use default address 0 | ||
+ | |||
+ | mcp.pinMode(0, OUTPUT); | ||
+ | } | ||
+ | |||
+ | |||
+ | // flip the pin #0 up and down | ||
+ | |||
+ | void loop() { | ||
+ | delay(100); | ||
+ | |||
+ | mcp.digitalWrite(0, HIGH); | ||
+ | |||
+ | delay(100); | ||
+ | |||
+ | mcp.digitalWrite(0, LOW); | ||
+ | }</nowiki> | ||
{{MCP23017-TRAILER}} | {{MCP23017-TRAILER}} |
Version du 22 juin 2013 à 11:33
En cours de traduction/élaboration. |
Code
Voici le code issu du programme toggle.pde de la librairie Adafruit-MCP23017-Arduino-Library.
/* Exemple toggle.pde Utilise la librairie Adafruit-MCP23017 pour changer une sortie du MCP23017. Code écrit par LadyAda pour AdaFruit Industries [www.adafruit.com] TRADUCTION FRANCAISE par Meurisse D. pour MCHobby.be [www.mchobby.be], CC-BY-SA pour traduction TUTORIEL #include <Wire.h> #include "Adafruit_MCP23017.h" // Basic pin reading and pullup test for the MCP23017 I/O expander // public domain! // Connect pin #12 of the expander to Analog 5 (i2c clock) // Connect pin #13 of the expander to Analog 4 (i2c data) // Connect pins #15, 16 and 17 of the expander to ground (address selection) // Connect pin #9 of the expander to 5V (power) // Connect pin #10 of the expander to ground (common ground) // Output #0 is on pin 21 so connect an LED or whatever from that to ground Adafruit_MCP23017 mcp; void setup() { mcp.begin(); // use default address 0 mcp.pinMode(0, OUTPUT); } // flip the pin #0 up and down void loop() { delay(100); mcp.digitalWrite(0, HIGH); delay(100); mcp.digitalWrite(0, LOW); }
Source: Librairie MCP23017 d'AdaFruit Industries
Tutoriel réalisé par Meurisse D pour MCHobby basé sur la librairie MCP23017 de LadyAda (AdaFruit Industries).
Traduit avec l'autorisation d'AdaFruit Industries - Translated with the permission from Adafruit Industries - www.adafruit.com
Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : « Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.
L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.