This page contains supplementary materials for 22 Swamps Towards the Abolishment of the Sun.
Where applicable, these files are dedicated to the public domain under CC0 1.0.

Instrument 3D Schematic
instrument-body.blend

Circuit Diagram
circuit.png

Arduino Sketch
asche.ino

// Preliminary copy of the source code. Not yet feature-complete. ;>

// https://www.arduino.cc/reference/en/libraries/capacitivesensor/
// Arduino CapacitiveSensor. Author: Paul Bagder, Paul Stoffregen
#include <CapacitiveSensor.h>
// https://www.arduino.cc/reference/en/libraries/usb-midi/
// Arduino USB-MIDI Transport. Author: lathoub
#include <USB-MIDI.h>

float peakPitch = 0;
float mappedPitch = 0;
float currPitch = 0;

CapacitiveSensor   cs_9_8 = CapacitiveSensor(3,4); // 1M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil
//CapacitiveSensor   cs_4_8 = CapacitiveSensor(8,9); // 1M resistor between pins 4 & 8, pin 8 is sensor pin, add a wire and or foil

USBMIDI_CREATE_DEFAULT_INSTANCE();


void setup()                    
{
   Serial.begin(9600);
    MIDI.begin(1);
}

int thresh = 1500;

int currentRead = 0;

int pot0 = 0;
int pot1 = 0;
int pot2 = 0;
int pot3 = 0;

void loop()                    
{

   long sensor1 = 0; 
   long sens2 = 0;

   currentRead += 1;
  
   currPitch += cs_9_8.capacitiveSensor(40);

   if (currentRead >= 4)
   {
      currPitch /= 4;

      Serial.print(currPitch); Serial.print(",");

      if (currPitch > 0) // Get upper part of the frequency spectrum of the pitch input
      {

        if (currPitch > 10000)
          currPitch = peakPitch;
        
        if (currPitch > peakPitch) // Check if the current pitch is higher than the previous
          peakPitch = currPitch; // If it's higher, set the peak at the current pitch

        mappedPitch = map(currPitch, 0, peakPitch, -10, 127); // Maps readings to the appropriate frequency range I want to use. The ADC readings from 550 to 1023 are mapped to frequencies between 5000 and 10Hz. I noticed that the antenna was having constant peaks at 400-500, irrelevant of the objects near it, so I used the map function to get rid of values under 550
      }
      else peakPitch = 0; 

      Serial.print(mappedPitch);
      
      if(mappedPitch > 0)
      {
         if(digitalRead(2) == HIGH)
         {
          MIDI.sendControlChange(3, mappedPitch, 1);
         }
      }
      
      currentRead = 0;
      currPitch = 0;

      Serial.print(",");
      Serial.println(0);
      
   }
   
   if (pot0 <= int(analogRead(A0)/8) - 2 || pot0 >= int(analogRead(A0)/8) + 2)
   {
      MIDI.sendControlChange(10, int(analogRead(A0)/8), 1);
      pot0 = int(analogRead(A0)/8);
   }
   if (pot1 <= int(analogRead(A1)/8) - 2 || pot1 >= int(analogRead(A1)/8) + 2)
   {
      MIDI.sendControlChange(11, int(analogRead(A1)/8), 1);
      pot1 = int(analogRead(A1)/8);
   }
   if (pot2 <= int(analogRead(A2)/8) - 2 || pot2 >= int(analogRead(A2)/8) + 2)
   {
      MIDI.sendControlChange(12, int(analogRead(A2)/8), 1);
      pot2 = int(analogRead(A2)/8);
   }
   if (pot3 <= int(analogRead(A3)/8) - 2 || pot3 >= int(analogRead(A3)/8) + 2)
   {
      MIDI.sendControlChange(13, int(analogRead(A3)/8), 1);
      pot3 = int(analogRead(A3)/8);
   }
     
     
   delay(10);
}