top of page
  • Writer's picture1/4" Jack Of All Trades

Physical Computing Week 3 - Feedback

Updated: Jan 7, 2021

Lab 2 - Had some problems with this one (and LDRs in general), but I think I was using wrong resistors due to my colour blindness.

My idea was to create a sound art installation involving the ultrasonic Theremin proposed in my previous post, that I have since prototyped on a breadboard with a piezo and a quick attempt data smoothing (as I was getting weird spikes).

A motor would control a surface/obstacle that moves around the Theremin's ultrasonic field (apparently hard surfaces work better than soft), thus changing the sound - the obstacle's movement could be controlled by a delayed version of the ultrasonic readings (with a small element of randomness to avoid being potentially stuck in a repetitive loop). Mapping values to musical notes also an option.

Human interaction could be using a potentiometer (or several) to change things such as the wave shape / the speed of the motor, or potentially using IR control from a modified TV remote to effect parameters, such as speed, musical scale etc.

Planning to use wavetable synth library next and connect up to actual speakers to get a wider range of audio.

Code with smoothing:

const int pingPin = 7; // Trigger Pin of Ultrasonic Sensor
const int echoPin = 6; // Echo Pin of Ultrasonic Sensor
int sensorLow = 1023;
int sensorHigh = 0;
int sensorValue = 0;

const int numReadings = 10;

int readings[numReadings];      // the readings from the analog input
int readIndex = 0;              // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average
int index = 0;

void setup() 
   Serial.begin(9600); // Starting Serial Terminal
  for (int thisReading = 0; thisReading < numReadings; thisReading++) 
    readings[thisReading] = 0;

void loop() 
   long duration, cm; 
   pinMode(pingPin, OUTPUT);
   digitalWrite(pingPin, LOW);
   digitalWrite(pingPin, HIGH);
   digitalWrite(pingPin, LOW);
   pinMode(echoPin, INPUT);

   duration = pulseIn(echoPin, HIGH);
   cm = microsecondsToCentimeters(duration);
  // Serial.print(cm);
  // Serial.println();

 total = total + cm;
 index = index + 1;

 if (index >= numReadings)
   index = 0;
   average = total / numReadings;
   Serial.print("Dist_avg = ");
   total = 0;

int pitch = average * 5; 


long microsecondsToCentimeters(long microseconds) 
   return microseconds / 29 / 2;

23 views0 comments


bottom of page