Assignment: Input / Output Coincidence Lab Assignment
Collaborators:
Description
Tap for Light is a knock-senstive light controller. My prototype is made up of a trio of LEDs (red, green, blue) and a piezo speaker that is used to sense when an object hits the diffuser covering the LEDs. Tapping the diffuser makes the LEDs randomly change brightness, which makes the diffuser change color.
In a larger physical installation, think of a vibration-sensitive dance floor that changes color based on where and how people dance on the floor.
Components Used
Construction
The diffuser is placed on top of the LED trio, and the piezeo speaker is mounted undernearth the diffuser.
Arduino Code
/* Knock Sensor
* ----------------
*
* Program using a Piezo element as if it was a knock sensor.
*
* We have to basically listen to an analog pin and detect
* if the signal goes over a certain threshold. It writes
* "knock" to the serial port if the Threshold is crossed,
* and toggles the LED on pin 13.
*
* (cleft) 2005 D. Cuartielles for K3
*
* Modified by Andy Brooks, October 6, 2008
* andy@ischool.berkeley.edu
*/
int RedLEDval = 0;
int BlueLEDval = 0;
int GreenLEDval = 0;
int RedLEDpin = 13;
int BlueLEDpin = 11;
int GreenLEDpin = 12;
int knockSensor = 0;
byte val = 0;
int LEDsON = 50;
long randRED;
long randBLUE;
long randGREEN;
void setup() {
beginSerial(9600);
pinMode(RedLEDpin, OUTPUT);
pinMode(BlueLEDpin, OUTPUT);
pinMode(GreenLEDpin, OUTPUT);
}
void loop() {
val = analogRead(knockSensor);
if (val >= LEDsON) {
randRED = random(25, 255);
analogWrite(RedLEDpin, randRED);
randBLUE = random(25, 255);
analogWrite(BlueLEDpin, randBLUE);
randGREEN = random(25, 255);
analogWrite(GreenLEDpin, randGREEN);
Serial.print("Red: ");
Serial.println(randRED);
Serial.print("Green: ");
Serial.println(randGREEN);
Serial.print("Blue: ");
Serial.println(randBLUE);
Serial.println();
delay(25);
}
delay(25); // we have to make a delay to avoid overloading the serial port
}
Video
As demonstration I shot a video where I'm hitting the diffuser with a pencil to make it change color. Please excuse the cinematography.