For my temporal demonstration, I created an arduino circuit that uses the input from a sonar sensor to modulate the frequency of a tone as well as the speed at which the tone is beeping. It augments human perception of time by allowing changes in distance to be heard as changes in pitch and rhythm. The basic idea for the demo was a proximity alarm that speeds up and increases in pitch as the object gets closer to the sensor.

References:

Technical Exercise Sequence: Read Sonar

Technical Exercise Sequence: Event Loop Programming

Code:


// pin assignments
const int speaker1 = 4;
const int speaker2 = 5;
const int Trigger = 8;
const int Echo = 7;

// The rated distance limit of the sensor, in cm.
const int MAX_DISTANCE = 450;

// A typical speed of sound, specified in cm/sec.
const long SOUND_SPEED = 34000;

const long Timing = (2 * MAX_DISTANCE * 1000000)/SOUND_SPEED;



void setup()
{
 
 // Initialize speaker pins as outputs
 pinMode( speaker1, OUTPUT );
 pinMode( speaker2, OUTPUT );
 
 // Initialize the trigger pin for output.
 pinMode(Trigger, OUTPUT);
 digitalWrite(Trigger, LOW);
 
 // Initialize the echo pin for input.
 pinMode(Echo, INPUT);
}


// Global variables.
long inputValue = 0;
long input_interval = 1000;
long nextTime_input = 0;



long nextTime1 = 0; // timestamp in microseconds for when next to update speaker1
long nextTime2 = 0; // timestamp in microseconds for when next to update speaker2
long restTime = 0; // timestamp in microseconds for when to rest

int state1 = LOW; 
int state2 = LOW; // start both outputs at LOW



void loop()
{
 // read the current time in microseconds
 long now = micros();

if (now > nextTime_input) {

// reset timer
 nextTime_input = now + input_interval;

// set inputValue to (duration of ping)*2
 inputValue = ping_sonar()*2;
 
 }
 
 // resting interval to make the speaker beep
 if (now > restTime) {
 digitalWrite( speaker1, LOW);
 digitalWrite( speaker2, LOW);

restTime = now + (inputValue*50); // scaled by 50 to make beeping interval slower than the pitch modulation interval
 delay(10); // delay to make it possible to hear the beeping
 }

else {
 
 if (now > nextTime1) {

// reset timer
 nextTime1 = now + inputValue;

// toggle the state1 variable
 state1 = !state1;

// update the state of speaker1
 digitalWrite( speaker1, state1 );
 }


 if (now > nextTime2) {

// reset timer
 nextTime2 = now + inputValue;
 
 // toggle the state2 variable
 state2 = !state2;

// update the state of speaker2
 digitalWrite( speaker2, state2 );
 }
 }
}

// ping_sonar function returns the time it takes for a ping to bounce back
long ping_sonar(void)
{
 // Generate a short trigger pulse.
 digitalWrite(Trigger, HIGH);
 delayMicroseconds(10);
 digitalWrite(Trigger, LOW);

// Measure the pulse length
 return pulseIn(Echo, HIGH, Timing);
}