👾

Physical Computing Final

Physical Computing Final

Resources

p5 Web Serial Documentation GitHub GuideGitHub Guide

Lab: Serial Input to p5.js Using the p5.webserial Library – ITP Physical ComputingLab: Serial Input to p5.js Using the p5.webserial Library – ITP Physical Computing

Adafruit Learning System Adafruit I2S MEMS Microphone BreakoutAdafruit Learning System Adafruit I2S MEMS Microphone Breakout

Paper Prototypes Planning: Unsupported EmbedUnsupported Embed

Phase 1: Testing microphone sensor

We considered airflow sensors, Adafruit Industries Adafruit Sensirion SHTC3 Temperature & Humidity SensorAdafruit Industries Adafruit Sensirion SHTC3 Temperature & Humidity Sensor and ended up running a first test and wiring for Adafruit I2S MEMS Microphone Breakout - SPH0645 with Arduino Nano 33 IoT:

  • LRCLK/WS connects to A2 pin on Nano
  • BCLK connects to A3 pin on Nano
  • Data/SD connects to pin 4 on Nano

Arduino Example Code 1

/*
 This example reads audio data from an Invensense's ICS43432 I2S microphone
 breakout board, and prints out the samples to the Serial console. The
 Serial Plotter built into the Arduino IDE can be used to plot the audio
 data (Tools -> Serial Plotter)

 Circuit:
 * Arduino/Genuino Zero, MKR family and Nano 33 IoT
 * ICS43432:
   * GND connected GND DONE
   * 3.3V connected to 3.3V (Zero, Nano) or VCC (MKR) DONE
   * (LRCLK or) WS connected to pin 0 (Zero) or 3 (MKR) or A2 (Nano) 
   * CLK connected to pin 1 (Zero) or 2 (MKR) or A3 (Nano)
   * SD connected to pin 9 (Zero) or A6 (MKR) or 4 (Nano)

 created 17 November 2016
 by Sandeep Mistry
 */

#include <I2S.h>

void setup() {
  // Open serial communications and wait for port to open:
  // A baud rate of 115200 is used instead of 9600 for a faster data rate
  // on non-native USB ports
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start I2S at 8 kHz with 32-bits per sample
  if (!I2S.begin(I2S_PHILIPS_MODE, 8000, 32)) {
    Serial.println("Failed to initialize I2S!");
    while (1); // do nothing
  }
}

void loop() {
  // read a sample
  int sample = I2S.read();

  if (sample) {
    // if it's non-zero print value to serial
    Serial.println(sample);
  }
}

Arduino Code 2 Working

#include <I2S.h>

void setup() {
  Serial.begin(115200);
  while (!Serial) {
    ; // Wait for serial port to connect. Needed for native USB only
  }

  // Start I2S at 8 kHz with 32-bits per sample
  if (!I2S.begin(I2S_PHILIPS_MODE, 8000, 32)) {
    Serial.println("Failed to initialize I2S!");
    while (1); // do nothing
  }
}

void loop() {
  // Read a sample from the I2S microphone
  int sample = I2S.read();

  // Only send significant audio levels
  if (sample > 100) { // Threshold to filter out background noise
    Serial.println(abs(sample) / 100); // Scale down data for p5.js
  }
}

p5 Web Serial Trial Code

experiment_arduino_microphone by ineslucas -p5.js Web Editorexperiment_arduino_microphone by ineslucas -p5.js Web Editor

Delicate gold copy copy copy by ranjanir -p5.js Web EditorDelicate gold copy copy copy by ranjanir -p5.js Web Editor / / Working Code, but not the microphone ended up not being the interaction we were looking for, as you had to breath into it at an angle.

Phase 2: Setting on a concept & planning out layers

image

Phase 3: Building a Velostat circular mat

Instructables O-matInstructables O-mat → Our classmate Nasif was incredibly helpful in the testing phase, and we ended up verifying it works, the structure and subsequently ordering the needed quantities. Velostat purchased from Less EMF Paints ArchivesLess EMF Paints Archives.

The original Processing Code for a square grid is as follows below. We figured out we don’t necessarily need to use Processing as that would mean learning Java.

Java Code for a squared coppered tape grid

Through the p5 prototyping below, we realised we need around 90 sections (30 below divided by 3, creating 90).

Problem: getting enough pins to connect around 90 sections

  • Can we use the I2C bus and an I2C multiplexer for analog signal from copper + velostat? Would the output of I2C communication be helpful in retrieving the range output from the pressure applied on the Velostat?
  • It seems like the Arduino Nano only takes 3 multiplexers (3 * 5 wires needed and a max of 19 Arduino pins). For the Sparkfun multiplexer sparkfun SparkFun Analog/Digital MUX Breakout - CD74HC4067sparkfun SparkFun Analog/Digital MUX Breakout - CD74HC4067, that would mean 3*16 = 48 regions of sensing, but it’s looking like we need something closer to 90. It’s possible I’m being shortseighted. Would using an array mean we need more connections or less? More actually.

Solution is basically between using an Arduino Mega with 54 pins (16 with PWM) and the Spark Fun or using more I2C multiplexers? [ Question for Prof ]

image

How to use TX / RX to connect 2 Arduinos: Instructables I2C Between ArduinosInstructables I2C Between Arduinos

Class feedback session: Solution

  • We’re building a capacitive sensor. // custom pressure sensor.
    • When Serial is open, it can’t be open to p5 and TouchDesigner at the same time. There however can be two way serial. There’s also other ways to communicate besides serial - like Midi or OSC.
  • Main issue is that 90 is a lot of sections and a lot of code.
    • Actually we can use 2 sections ⭕️, making it 32 total or fewer sections in the palm and more in the fingertips = 15 + 30.
  • Need to verify this information but the Arduino Mega has no wifi.
  • I can chain together the Analog/Digital MUX, which means that the amount of Nano pins wouldn’t be a constraint.
  • Sparkfun Analog to digital MUX Multiplexer has a different function than the I2C multiplexer. An I2C multiplexer is for connecting I2C devices that have the same address, so that way you don’t need to change the addresses, you can target the multiplexer instead.

Next steps

Playtest where we have a few sections of the circular sensor working. Visuals can be crappy.