This is a device that perceives motion in fidgeting to output a feedback noise. People tend to fidget subconsciously it but if they wear this device they will immediately realize they are shaking their leg/foot/etc. I also thought it would be interesting to perceive noise from human behavior that is in his or her organic time frame that is not always intended to create a rhythm or follow a pattern.

 

int prev_z = -1;
#define SPEAKER_PIN 5

void setup()
{
 pinMode(SPEAKER_PIN, OUTPUT);
 digitalWrite(SPEAKER_PIN, LOW);
 Serial.begin(9600); 
}
void loop()
{ 
#define OFFSET 335
#define SCALE 0.013
 int z_raw = analogRead(2);
 float z = ((z_raw - OFFSET) * SCALE)-0.83;
 
 // use rounding to smooth and ignore noise
 float sensitivity = .5;
 z = round(z*sensitivity)/sensitivity;
 
 // turn z into -1 or 1
 int unit_z = z/(abs(z));
 
 // ignore zeros
 if (unit_z == 0) {
 unit_z = -1;
 }
 
 // make a noise if z changed to going down
 if( unit_z < prev_z){
 digitalWrite(LED_BUILTIN, HIGH);
 tone(SPEAKER_PIN, 50);
 }
 
 // otherwise do not output noise
 else {
 digitalWrite(LED_BUILTIN, LOW);
 noTone(SPEAKER_PIN);
 }
 
 // update previous z for next loop
 prev_z = unit_z;
 
 Serial.print(unit_z);
 delay(50);
}