Outils pour utilisateurs

Outils du site


start:arduino:mcp23017:dfrobot

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
start:arduino:mcp23017:dfrobot [2022/03/29 10:49] – [Exemple de code 4- Interruption IO] gerardadminstart:arduino:mcp23017:dfrobot [2023/01/27 16:08] (Version actuelle) – modification externe 127.0.0.1
Ligne 2: Ligne 2:
  
 [[https://wiki.dfrobot.com/Gravity:%20MCP23017%20IIC%20to%2016%20Digital%20IO%20Expansion%20Module%20SKU:%20DFR0626|PCP23017 DFROBOT EN]] [[https://wiki.dfrobot.com/Gravity:%20MCP23017%20IIC%20to%2016%20Digital%20IO%20Expansion%20Module%20SKU:%20DFR0626|PCP23017 DFROBOT EN]]
 +
 +==== Achat ====
 +
 +[[https://www.gotronic.fr/art-module-d-expansion-i2c-gravity-dfr0626-31815.htm| Achat MCP23017 Gotronic  ]]
 +
 +[[https://shop.mchobby.be/fr/ci/218-mcp23017-extension-16-entree-sortie-i2c-3232100002180.html| Achat MCP23017 McHobby]]
 +
 +[[https://www.dfrobot.com/product-2002.html|Achat MCP23017 DFRobot ]]
  
 {{ :start:arduino:mcp23017:capture_du_2022-03-29_10-16-31.jpg?direct&400 |}} {{ :start:arduino:mcp23017:capture_du_2022-03-29_10-16-31.jpg?direct&400 |}}
Ligne 515: Ligne 523:
 Appuyez sur le bouton sur PAO ou PB7, le résultat suivant sera imprimé sur le port série. Appuyez sur le bouton sur PAO ou PB7, le résultat suivant sera imprimé sur le port série.
  
 +{{ :start:arduino:mcp23017:0df48411de0ff0f98a28de41cb1254eb.png?direct&400 |}}
  
 +====Connexion en cascade====
 +
 +{{ :start:arduino:mcp23017:d3c707ef60a2006d9fc16a974c2d42e9.jpeg?direct&400 |}}
 +
 +{{ :start:arduino:mcp23017:f3259a825dac9d179941eef88353e3dd.jpeg?direct&400 |}}
 +
 +==== Schema du DFT0626 - MCP23017 DFROBOT ====
 +
 +{{ :start:arduino:mcp23017:aa62e2f3d0876cac7a28fc17bf3ef7f2.jpg?direct&400 |}}
 +
 +
 +==== Doc technique MCP23017 ====
 +
 +[[https://dfimg.dfrobot.com/nobody/wiki/9401e19f637db318a458f6f5f468413b.pdf|Doc technique MCP23017 .pdf EN]]
 +
 +
 +===== Programme APC220 (Sans fil) et MCP23017  et ESP32 =====
 +
 +<code c Emmision_ESP32_LED_BP_APC220_MCP23017.ino>
 +#include <DFRobot_MCP23017.h>
 +#include <HardwareSerial.h>
 +
 +HardwareSerial Sender(2);   // Define a Serial port instance called 'Sender' using serial port 1
 +
 +#define Sender_Txd_pin 17
 +#define Sender_Rxd_pin 16
 +
 +int EtatLED = 0;
 +int  EtatBP = 0;
 +int  EtatPrecd = 0;
 +int EtatLEDPrecd =0;
 +bool Unefois = false;
 +
 +
 +DFRobot_MCP23017 mcp027(Wire, /*addr =*/0x27);//constructor, change the Level of A2, A1, A0 via DIP switch to revise I2C address within 0x20~0x27
 +
 +//Prepare: connect the LED to a digital pin of IO expansion board(eg:eGPA7)
 +void setup(void)
 +{
 + Serial.begin(115200);                                             // Define and start serial monitor
 + Sender.begin(9600, SERIAL_8N1, Sender_Txd_pin, Sender_Rxd_pin);
 + 
 +  while(mcp027.begin() != 0){
 +    Serial.println("Initialization of the chip failed, please confirm that the chip connection is correct!");
 +     delay(1000);
 +  }
 + 
 + 
 +  mcp027.pinMode(/*pin = */mcp027.eGPB0, /*mode = */OUTPUT);
 +  mcp027.pinMode(/*pin = */mcp027.eGPA0, /*mode = */INPUT);
 + 
 +}
 +
 +void loop(void)
 +{
 +      EtatPrecd = EtatBP ;
 +      EtatBP = mcp027.digitalRead(/*pin = */mcp027.eGPA0);
 +      delay(100);
 +      //Serial.print("EtatBP  :");
 +      //Serial.println(EtatBP);
 +      /*delay(1000);
 +      Serial.print("verrou1  :");
 +      Serial.println(verrou);*/
 + 
 + if  ((EtatPrecd == 1) && (EtatBP == 0 )) { 
 +      Serial.print("BP pressé  :");
 +      //Serial.println(verrou);
 +      EtatLEDPrecd = EtatLED;
 +      EtatLED = !EtatLED;
 +      Serial.print("EtatLED  :");
 +      Serial.println(EtatLED);
 +      }  
 +  if(EtatLED == 0 ){
 +  mcp027.digitalWrite(mcp027.eGPB0, LOW); 
 +  if ( Unefois == false ) {
 +      Sender.print("allume"); 
 +      Unefois = !Unefois ;
 +  }   
 +  Serial.print("Valeur transmise avec appui BP  : ");
 +  Serial.println(EtatLED );
 +  delay(100);
 + 
 +  }
 +  else if  (( EtatLED ==1 ) && (EtatLEDPrecd == 0)) {
 +  mcp027.digitalWrite(mcp027.eGPB0, HIGH);
 +  //Sender.print(EtatLED ); 
 +  if ( Unefois == true) {
 +      Sender.print("eteint"); 
 +      Unefois = !Unefois ;
 +  }   
 +  Serial.print("Valeur transmise sans appui BP   : ");
 +  Serial.println(EtatLED );
 +  delay(100);
 +  }
 +
 +}
 +</code>
  
  
  
/home/chanteri/www/fablab37110/data/attic/start/arduino/mcp23017/dfrobot.1648543761.txt.gz · Dernière modification : 2023/01/27 16:08 (modification externe)