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

    Visualization: 2×2 Matrix

    This code is great for visualizing pressure sensor matrices using a grid of squares that are filled with gray-scale values from 0-255, corresponding to the pressure sensor value.

    ARDUINO CODE :::

    /*
    2×2 presure sensor matrix code,
    where each row/column is connected to an individual analog pin
    >> github plusea
    */

    int rowPin1 = A2;
    int rowPin2 = A3;
    int colPin1 = 10;
    int colPin2 = 11;
    int sensorValues[] = {
    0,0,0,0};

    void setup() {
    pinMode(rowPin1, INPUT);
    pinMode(rowPin2, INPUT);
    digitalWrite(16, HIGH);
    digitalWrite(17, HIGH);
    pinMode(colPin1, OUTPUT);
    pinMode(colPin2, OUTPUT);
    Serial.begin(9600);
    }

    void loop() {
    digitalWrite(colPin1, HIGH);
    digitalWrite(colPin2, LOW);
    sensorValues[0] = analogRead(rowPin1);
    sensorValues[1] = analogRead(rowPin2);
    delay(10);
    digitalWrite(colPin1, LOW);
    digitalWrite(colPin2, HIGH);
    sensorValues[2] = analogRead(rowPin1);
    sensorValues[3] = analogRead(rowPin2);
    delay(10);
    Serial.print(sensorValues[0]);
    Serial.print(‘,’);
    Serial.print(sensorValues[1]);
    Serial.print(‘,’);
    Serial.print(sensorValues[2]);
    Serial.print(‘,’);
    Serial.print(sensorValues[3]);
    Serial.println();
    }

    PROCESSING CODE :::

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

    Reads 4 analog inputs and visualizes them by drawing a 2×2 grid,
    using grayscale shading of each square to represent sensor value.
    >> http://www.kobakant.at/DIY/?cat=347
    */

    import processing.serial.*;

    Serial myPort; // The serial port
    int maxNumberOfSensors = 4;
    float[] sensorValue = new float[maxNumberOfSensors]; // global variable for storing mapped sensor values
    float[] previousValue = new float[maxNumberOfSensors]; // array of previous values
    int rectSize = 200;

    void setup () {
    size(600, 600); // set up the window to whatever size you want
    println(Serial.list()); // List all the available serial ports
    String portName = Serial.list()[0];
    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 () {
    fill(sensorValue[0]);
    rect(width/2-rectSize, height/2-rectSize, rectSize,rectSize); //top left
    fill(sensorValue[0]);
    rect(width/2, height/2-rectSize, rectSize,rectSize); //top right
    fill(sensorValue[0]);
    rect(width/2-rectSize, height/2, rectSize,rectSize); //bottom left
    fill(sensorValue[0]);
    rect(width/2, height/2, rectSize,rectSize); //bottom right
    }

    void serialEvent (Serial myPort) {
    String inString = myPort.readStringUntil(‘\n’); // get the ASCII string

    if (inString != null) { // if it’s not empty
    inString = trim(inString); // trim off any whitespace
    int incomingValues[] = int(split(inString, “,”)); // 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);
    }
    }
    }
    }

    Video:



    Leave a comment