Example Projects
Workshops
Announcements
Actuators
Connections
Power
Sensors
Traces

Circuits and Code Wireless

Meet the Materials
Conductive Materials
Non-Conductive Materials
Tools
Techniques
Thinking Out Loud
Circuits and Code
  • Arduino Overview
  • Arduino as Bluetooth HID
  • ATtiny: 7-Segment Display
  • ATtiny: Capacitive Sensing
  • ATtiny: Programming
  • ATtiny Serial & Wireless Boards!
  • ATtiny: Soft Serial
  • ATtiny: Sound
  • ATtiny: Soft Fade
  • Bits and Bytes Binary numbers
  • Multiplexed Matrix
  • Controlling EL Panel and EL Wire
  • EL panel/wire inverter hack
  • EMF amplifier
  • Heat Controlling Circuit
  • LED with Light Sensor
  • Lilypad XBee Shield
  • My First Arduino Connection Check
  • pressure matrix code + circuit
  • Pull-up Resistors
  • Rabbit Control Client on Bela
  • RabbitControl on Bela
  • RGB Colour Fade
  • simple heat circuit
  • Solar Powered Motor Circuit
  • Sound Amplifying Circuits
  • Graphing and Drawing Sensor Values
  • Teensy as HID Device
  • Transistor Switch
  • Volume Detection
  • Visualization: 2x2 Matrix
  • Visualization: Drawing
  • Visualization: Graph
  • Visualization: Pressure Sensor Matrix
  • Visualization: Touchpad
  • Voltage Divider
  • Voltage Divider with Arduino
  • What is Variables?
  • Support the creation of content on this website through PATREON!
  • About
  • E-Textile Events
  • E-Textile Spaces
  • Newsletter
  • Print & Publications
  • E-Textile Shopping

  • SEARCH
    Content by Mika Satomi and Hannah Perner-Wilson
    E-Textile Tailor Shop by KOBAKANT
    The following institutions have funded our research and supported our work:

    Since 2020, Hannah is guest professor of the Spiel&&Objekt Master's program at the University of Performing Arts Ernst Busch in Berlin

    From 2013-2015 Mika was a guest professor at the eLab at Kunsthochschule Berlin-Weissensee

    From July - December 2013 Hannah was a researcher at the UdK's Design Research Lab

    From 2010-2012 Mika was a guest researcher in the Smart Textiles Design Lab at The Swedish School of Textiles

    From 2009 - 2011 Hannah was a graduate student in the MIT Media Lab's High-Low Tech research group led by Leah Buechley


    In 2009 Hannah and Mika were both research fellows at the Distance Lab


    Between 2003 - 2009 Hannah and Mika were both students at Interface Cultures
    We support the Open Source Hardware movement. All our own designs published on this website are released under the Free Cultural Works definition
    Circuits and Code

    pressure matrix code + circuit

    In this post I want to try and explain how a pressure matrix built from conductive rows and columns with a piezoresistive material (Eeonyx, Velostat) in between works, how to wire it up to an Arduino and write the Arduino code that will parse through the rows and columns to read the individual pressure points at each row/column intersection.

    1) how a piezoresistive pressure sensor works
    2) wiring matrix to arduino
    3) the matrix code

    matrix illustrations

    More illustrations >> https://www.flickr.com/photos/plusea/albums/72157691421107353

    Translating WORLD to COMPUTER:
    matrix illustrations


    1) how a piezoresistive pressure sensor works

    the piezoresistive effect is described as “a change in the electrical resistivity of a semiconductor or metal when mechanical strain is applied”. How does this “change in electrical resistivity” happen?
    Together with Maurin D. and Adrian F., I’ve speculated about the factors that play into this, and have attempted to describe it more detail here:
    >> https://www.kobakant.at/DIY/?p=7832

    In this illustration I try to capture the fact that there is not only a change in resistance happening inside the material, but also between the electrodes and the material.
    Piezo/resistance

    In etextiles for piezoresistive materials, we most often use:
    – Velostat/Linqstat (because it is so easy and cheap to get, the downside being it is plastic sheet)
    – Eeonyx fabrics (hard to get)
    – knit/woven/felted steel fiber blends or steel fiber yarn blends (https://www.kobakant.at/DIY/?p=6005)

    And on either side of these materials we create conductors/leads/electrodes/probes by sewing lines of conductive thread, fusing strips of conductive fabric……

    There are many many ways to assemble a fabric pressure sensor or pressure sensor matrix. Here are a few:

    SOFT

    With the same principal you can go on to make larger soft fabric touchpads like this one:
    >> https://www.kobakant.at/DIY/?p=7651

    SEWN directly onto the piezoresistive

    >> https://www.kobakant.at/DIY/?p=6900

    WOVEN from strips

    >> https://www.kobakant.at/DIY/?p=4296

    WOVEN through holes

    >> https://www.kobakant.at/DIY/?p=6889

    WOVEN & stretchy

    >> https://www.kobakant.at/DIY/?p=7217

    STRETCHY

    And stretchy ones too:
    >> http://www.kobakant.at/DIY/?p=7639

    in NEOPRENE

    >> https://www.kobakant.at/DIY/?p=213

    KAPTON and copper tape

    >> https://www.kobakant.at/DIY/?p=7443
    Type-pad pressure matrix


    3×3 Paper Matrix Example

    This is the 3 x 3 paper touchpad that you can quickly assemble in order to go through the example and learn to build the circuity and write the code.

    Photos >> https://www.flickr.com/photos/plusea/albums/72157708415692535

    template to print on paper:
    3x3 paper matrix template
    3x3 paper matrix template

    print, cut, tape, assemble:
    Pressure matrix workshop
    Pressure matrix workshop
    Pressure matrix workshop


    2) wiring matrix to arduino

    TRANSLATING: world –> computer
    – resistance –> voltage
    – analog –> digital

    matrix illustrations


    TRANSLATING: resistance(ohm) –> voltage(volt)

    Ohm’s law: V = I x R

    matrix illustrations

    Velostat = fixed resistor
    Velostat = variable resistor

    matrix illustrations

    matrix illustrations

    matrix illustrations


    Voltage Divider:

    matrix illustrations

    matrix illustrations

    matrix illustrations

    matrix illustrations

    matrix illustrations

    matrix illustrations

    matrix illustrations


    3) the matrix code

    TRANSLATING: analog –> digital (using the ADC)
    ADC = Analog Digital Converter:
    analogRead(pin#);

    ARDUINO CODE:

    /*
    Pressure Sensor Matrix Code
    parsing through a pressure sensor matrix grid by switching individual
    rows/columns to be HIGH, LOW or INPUT (high impedance) to detect
    location and pressure.
    >> https://www.kobakant.at/DIY/?p=7443
    */

    #define numRows 3
    #define numCols 3
    #define sensorPoints numRows*numCols

    int rows[] = {A0, A1, A2};
    int cols[] = {5,6,7};
    int incomingValues[sensorPoints] = {};

    void setup() {
    // set all rows and columns to INPUT (high impedance):
    for (int i = 0; i < numRows; i++) {
    pinMode(rows[i], INPUT_PULLUP);
    }
    for (int i = 0; i < numCols; i++) {
    pinMode(cols[i], INPUT);
    }
    Serial.begin(9600);
    }

    void loop() {
    for (int colCount = 0; colCount < numCols; colCount++) {
    pinMode(cols[colCount], OUTPUT); // set as OUTPUT
    digitalWrite(cols[colCount], LOW); // set LOW

    for (int rowCount = 0; rowCount < numRows; rowCount++) {
    incomingValues[colCount * numRows + rowCount] = analogRead(rows[rowCount]); // read INPUT
    }// end rowCount

    pinMode(cols[colCount], INPUT); // set back to INPUT!

    }// end colCount

    // Print the incoming values of the grid:
    for (int i = 0; i < sensorPoints; i++) {
    Serial.print(incomingValues[i]);
    if (i < sensorPoints – 1) Serial.print(“\t”);
    }
    Serial.println();
    delay(10);
    }

    PROCESSING CODE:

    /*
    Code based on Tom Igoe’s Serial Graphing Sketch
    >> http://wiki.processing.org/w/Tom_Igoe_Interview

    Reads X analog inputs and visualizes them by drawing a grid
    using grayscale shading of each square to represent sensor value.
    >> http://howtogetwhatyouwant.at/
    */

    import processing.serial.*;

    Serial myPort; // The serial port
    int rows = 10;
    int cols = 10;
    int maxNumberOfSensors = rows*cols;
    float[] sensorValue = new float[maxNumberOfSensors]; // global variable for storing mapped sensor values
    float[] previousValue = new float[maxNumberOfSensors]; // array of previous values
    int rectSize = 0;
    int rectY;
    void setup () {
    size(600, 600); // set up the window to whatever size you want
    rectSize = width/rows;

    println(Serial.list()); // List all the available serial ports
    String portName = Serial.list()[1]; // set the number of your serial port!
    myPort = new Serial(this, portName, 9600);
    myPort.clear();
    myPort.bufferUntil(‘\n’); // don’t generate a serialEvent() until you get a newline (\n) byte
    background(255); // set inital background
    smooth(); // turn on antialiasing
    rectMode(CORNER);
    }

    void draw () {
    for (int i = 0; i < maxNumberOfSensors; i++) {
    fill(sensorValue[i]);
    rect(rectSize * (i%rows), rectY, rectSize, rectSize); //top left
    if((i+1) % rows == 0) rectY += rectSize;
    }
    rectY=0;
    }

    void serialEvent (Serial myPort) {
    String inString = myPort.readStringUntil(‘\n’); // get the ASCII string
    println(“test”);
    if (inString != null) { // if it’s not empty
    inString = trim(inString); // trim off any whitespace
    int incomingValues[] = int(split(inString, “\t”)); // convert to an array of ints

    if (incomingValues.length <= maxNumberOfSensors && incomingValues.length > 0) {
    for (int i = 0; i < incomingValues.length; i++) {
    // map the incoming values (0 to 1023) to an appropriate gray-scale range (0-255):
    sensorValue[i] = map(incomingValues[i], 0, 1023, 0, 255); // stretch 5×5
    println(sensorValue[i]); // print value to see
    }
    }
    }
    }

    matrix illustrations

    Internal pull-up resistor
    pinMode(pin#, INPUT_PULLUP);

    matrix illustrationsmatrix illustrations

    matrix illustrations

    2 sensors
    matrix illustrations

    3 sensors
    matrix illustrations

    6 sensors ?????????????
    matrix illustrations

    9 sensors !
    matrix illustrations


    CODE

    GROUND the pin:
    pinMode(pin#, OUTPUT);
    digitalWrite(pin#, LOW);

    matrix illustrations

    IGNOTE the pin:
    pinMode(pin#, INPUT);

    matrix illustrations

    1:
    matrix illustrations

    READ from this pin:
    pinMode(pin#, INPUT);
    analogRead(pin#);

    matrix illustrations

    READ from this intersection:
    matrix illustrations

    matrix illustrations

    2:
    matrix illustrations

    3:
    matrix illustrations

    4:
    matrix illustrations


    Wiring:
    matrix illustrations
    matrix illustrations



    Leave a comment