Category:IO Expander

From ElectroDragon Wiki
Revision as of 20:37, 5 February 2020 by Chao (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
  • PCF8574 / PCF8575 - I2C - common used for 1602
  • MCP23008 - I2C - 8-Bit I/O Expander with Serial Interface, - arduino library
  • MCP23017 - I2C - 16-Bit I/O Expander with Serial Interface,


PCF8575 Demo Code

Use Wire.write(B00000000); to write value to the pins.

#include <Wire.h>

byte address = 0x20;   // address of PCF8575 with A0-A2 connected to GND "B01000000"
byte input; // variable to receive the two bytes
byte c; // first of the two bytes to read
byte d; // second of the two bytes to read
int led = 13;

void setup()
{
   Wire.begin();       // join i2c bus 
   Serial.begin(9600); // used to Debug , Thanks PaulS
   pinMode(led, OUTPUT);
}

void loop(){
  
  
    input = Wire.requestFrom(0x20,2);
       
      c = Wire.read();
      d = Wire.read();
      Wire.endTransmission();
      
      if(bitRead(d,6) == 0) {
     digitalWrite(led, LOW); 
     delay(1000);
       }
       else {
         digitalWrite(13, HIGH);
       }
    Serial.println(c, BIN);  
    delay(100);
    Serial.println(d,BIN); 
    
    }      // send the data

Demo code

Pages in category "IO Expander"

The following 3 pages are in this category, out of 3 total.