Beste CebeciHeba Elidrisi
Published

Memoirs of Disappearing Earth

Memoirs of Disappearing Earth translates the live electrical current between human skin and changing landscapes into real-time soundscapes.

IntermediateWork in progress59
Memoirs of Disappearing Earth

Things used in this project

Software apps and online services

Arduino IDE
Arduino IDE
Arduino NANO ESP32
Arduino NANO ESP32
VCV Rack

Hand tools and fabrication machines

Drill / Driver, Cordless
Drill / Driver, Cordless

Story

Read more

Schematics

System Design Diagram

Code

Capacitive Sensor Midi Controller

Arduino
#include <BLEMIDI_Transport.h>
#include <hardware/BLEMIDI_ESP32.h>
BLEMIDI_CREATE_DEFAULT_INSTANCE()

struct TouchSensor {
  uint8_t pin;
  long touchMin;
  long touchMax;
  int lastCC;
};

TouchSensor sensors[] = {
  {4, 90000,  270000,  -1},
  {10, 72000,  110000, -1},
  {14, 86000,  260000, -1}
};

const int NUM_SENSORS = sizeof(sensors) / sizeof(sensors[0]);
bool isConnected = false;

void setup() {
  Serial.begin(115200);  // ADD THIS
  MIDI.begin();
  BLEMIDI.setHandleConnected([]() {
    isConnected = true;
  });
  BLEMIDI.setHandleDisconnected([]() {
    isConnected = false;
  });
}

void loop() {

  // PRINT RAW READINGS WHETHER CONNECTED OR NOT
  for (int i = 0; i < NUM_SENSORS; i++) {
    long raw = touchRead(sensors[i].pin);
    Serial.print("S");
    Serial.print(i + 1);
    Serial.print(":");
    Serial.print(raw);
    Serial.print("  ");
  }
  Serial.println();

  if (!isConnected) {
    delay(10);
    return;
  }

  for (int i = 0; i < NUM_SENSORS; i++) {
    long raw = touchRead(sensors[i].pin);
    long clamped = constrain(
      raw,
      sensors[i].touchMin,
      sensors[i].touchMax
    );
    int cc = map(
      clamped,
      sensors[i].touchMin,
      sensors[i].touchMax,
      0,
      127
    );

    if (abs(cc - sensors[i].lastCC) > 1) {
      MIDI.sendControlChange(
        i + 1,
        cc,
        1
      );
      sensors[i].lastCC = cc;
    }
  }
  delay(10);
}

Credits

Beste Cebeci
4 projects • 1 follower
Heba Elidrisi
4 projects • 1 follower

Comments