Video Player
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | 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); } |
Leave a Reply
You must be logged in to post a comment.