Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO with MCP23017 IO Expansion and TTP233 Touch Sensors Interface

View and Edit Project In Cirkit DesignerImage of Arduino UNO with MCP23017 IO Expansion and TTP233 Touch Sensors Interface

Circuit Documentation

Summary of the Circuit

This circuit is designed to interface an Arduino UNO with multiple TTP233 touch sensors through two MCP23017 I/O expansion boards. The Arduino UNO reads the state of the touch sensors and outputs a serial message indicating which sensor was activated. The touch sensors are powered by the 5V supply from the Arduino and are connected to the MCP23017 boards, which expand the number of input pins available to the Arduino. The MCP23017 boards communicate with the Arduino over the I2C bus.

Component List

Arduino UNO

MCP23017 I/O Expansion Board

Touch Sensor TTP233

Wiring Details

Arduino UNO

MCP23017 I/O Expansion Board

Touch Sensor TTP233

Documented Code

/*
 * This Arduino Sketch reads inputs from TTP223 touch sensors connected to
 * MCP23017 IO expansion boards. When a touch sensor is activated, the
 * Arduino sends a serial message indicating which sensor was activated.
 */

#include <Wire.h>
#include <Adafruit_MCP23017.h>

Adafruit_MCP23017 mcp1;
Adafruit_MCP23017 mcp2;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  mcp1.begin(0); // Default address 0x20
  mcp2.begin(1); // Address 0x21

  // Initialize MCP23017 pins as inputs
  for (int i = 0; i < 3; i++) {
    mcp1.pinMode(i, INPUT);
    mcp2.pinMode(i, INPUT);
  }
}

void loop() {
  // Check sensors on MCP1
  for (int i = 0; i < 3; i++) {
    if (mcp1.digitalRead(i) == LOW) { // Assuming active low
      Serial.print("Sensor ");
      Serial.print(i + 1);
      Serial.println(" on MCP1 activated");
      delay(500); // Debounce delay
    }
  }

  // Check sensors on MCP2
  for (int i = 0; i < 1; i++) {
    if (mcp2.digitalRead(i) == LOW) { // Assuming active low
      Serial.print("Sensor ");
      Serial.print(i + 1);
      Serial.println(" on MCP2 activated");
      delay(500); // Debounce delay
    }
  }
}

The code initializes two MCP23017 instances and sets up the first three pins of each as inputs. In the main loop, it checks the state of these pins and prints a message to the serial monitor if a touch sensor connected to these pins is activated. The sensors are assumed to be active low, meaning they will be read as LOW when touched.