Codey OnlineArduino- & ESP32-Komponentenbibliothek › MCP23017 Inputs (0x20)
MCP23017 Inputs (0x20)
Schnittstelle

MCP23017 Inputs (0x20)

Der MCP23017 ist ein I2C-basierter 16-Bit-I/O-Expander mit zwei 8-Bit-GPIO-Ports (Port A und Port B) zum Einlesen digitaler Eingänge und zum Steuern von Ausgängen. Er kommuniziert über SDA/SCL mit der I2C-Adresse 0x20 und nutzt Interrupt-Ausgänge (INTA/INTB), um Änderungen an Eingängen zu signalisieren, plus Anschlüsse für Versorgung und GND sowie einen Reset-Pin.

Breite: 20.8 mm

Pinbelegung — MCP23017 Inputs (0x20)

Pin Signal Beschreibung
SCL SCL I2C clock line for communication with the MCP23017 at address 0x20.
SDA SDA I2C data line for communication with the MCP23017 at address 0x20.
GND ground Ground reference for the MCP23017 input expander.
VCC power Logic supply voltage for the MCP23017 board.
A2 digital I2C address-select input A2 for setting the MCP23017 address.
A1 digital I2C address-select input A1 for setting the MCP23017 address.
A0 digital I2C address-select input A0 for setting the MCP23017 address.
RESET reset Active-low reset input for the MCP23017 I/O expander.
NC/SO Not connected on I2C use; SPI SO function is unused for MCP23017 wiring.
NC/CS Not connected on I2C use; SPI chip-select function is unused for MCP23017 wiring.
VCC.1 power Logic supply voltage pin for the MCP23017 board.
INTB interrupt Interrupt output for GPIO port B; signals input changes when enabled.
B0 digital MCP23017 GPIO port B bit 0 input/output line.
B1 digital MCP23017 GPIO port B bit 1 input/output line.
B2 digital MCP23017 GPIO port B bit 2 input/output line.
B3 digital MCP23017 GPIO port B bit 3 input/output line.
B4 digital MCP23017 GPIO port B bit 4 input/output line.
B5 digital MCP23017 GPIO port B bit 5 input/output line.
B6 digital MCP23017 GPIO port B bit 6 input/output line.
B7 digital MCP23017 GPIO port B bit 7 input/output line.
GND.1 ground Ground reference pin for the MCP23017 board.
INTA interrupt Interrupt output for GPIO port A; signals input changes when enabled.
A0.1 digital MCP23017 GPIO port A bit 0 input/output line.
A1.1 digital MCP23017 GPIO port A bit 1 input/output line.
A2.1 digital MCP23017 GPIO port A bit 2 input/output line.
A3 digital MCP23017 GPIO port A bit 3 input/output line.
A4 digital MCP23017 GPIO port A bit 4 input/output line.
A5 digital MCP23017 GPIO port A bit 5 input/output line.
A6 digital MCP23017 GPIO port A bit 6 input/output line.
A7 digital MCP23017 GPIO port A bit 7 input/output line.

Beispielschaltplan — MCP23017 Inputs (0x20)

Von Nach Kabel
board:5V x1:VCC red
board:5V x1:VCC.1 red
board:GND x1:GND black
board:GND.1 x1:GND.1 black
board:A4 x1:SDA green
board:A5 x1:SCL blue
x1:A0 board:GND black
x1:A1 board:GND.1 black
x1:A2 board:GND.2 black
x1:RESET board:5V red

Arduino-Beispielcode — MCP23017 Inputs (0x20)

Dieses Beispiel wurde für das arduino-uno geschrieben und kompiliergeprüft. Codey Online passt es für jedes andere unterstützte Board an.

#include <Wire.h>
#include <Adafruit_MCP23X17.h>

Adafruit_MCP23X17 mcp;

const uint8_t inputPins[] = {0, 1, 2, 3}; // GPA0..GPA3
const char* pinNames[] = {"GPA0", "GPA1", "GPA2", "GPA3"};

void setup() {
  Serial.begin(115200);
  while (!Serial) {
    ;
  }

  Wire.begin();

  if (!mcp.begin_I2C(0x20)) {
    Serial.println("Could not find MCP23017 at I2C address 0x20.");
    while (1) {
      delay(10);
    }
  }

  for (uint8_t i = 0; i < 4; i++) {
    mcp.pinMode(inputPins[i], INPUT_PULLUP);
  }

  Serial.println("MCP23017 ready. Inputs are GPA0-GPA3 with internal pull-ups enabled.");
  Serial.println("Connect a switch from any input pin to GND to read LOW.");
}

void loop() {
  for (uint8_t i = 0; i < 4; i++) {
    int state = mcp.digitalRead(inputPins[i]);
    Serial.print(pinNames[i]);
    Serial.print(": ");
    Serial.println(state == LOW ? "PRESSED / LOW" : "RELEASED / HIGH");
  }
  Serial.println("---");
  delay(500);
}

Ähnliche Komponenten

16 Channel 12-Bit PWM Servo Driver I2C

16 Channel 12-Bit PWM Servo Driver I2C

Bau dein Arduino- oder ESP32-Projekt mit AI

Beschreib einfach, was du bauen willst. Codey Online schreibt den Code, zeichnet den Schaltplan, kompiliert alles und flasht dein Board direkt aus dem Browser.

Kostenlos starten