Wednesday, November 4, 2009
Prototype #7: MidTerm
Description:
We have taken our portable Prototype #6 and adapted it to become 'wearable'.
We switch our input back to the piezo element due to its robustness and ease of adaptability for the shoe.
Input:
Tapping of the shoe
Output:
LED turns ON and OFF
Setup:

Result:
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. If the Threshold
* is crossed, and toggles the LED on pin 13.
*
* Modified from one by (cleft) 2005 D. Cuartielles for K3
*/
int ledPin = 13;
int knockSensor = 2;
byte val = 0;
int statePin = LOW;
int THRESHOLD = 1; // if it's too sensitive then change this value
void setup()
{
pinMode(ledPin, OUTPUT);
}
void loop()
{
val = analogRead(knockSensor);
if (val >= THRESHOLD) { // check the piezo
statePin = !statePin; // sets the pin to the opposite state
digitalWrite(ledPin, statePin); // turn on or off the LED
}
}
http://electronics.divinechildhighschool.org/Home/Arduino-Lessons/analog-read-and-a-piezo
We have taken our portable Prototype #6 and adapted it to become 'wearable'.
We switch our input back to the piezo element due to its robustness and ease of adaptability for the shoe.
Input:
Tapping of the shoe
Output:
LED turns ON and OFF
Setup:

Result:
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. If the Threshold
* is crossed, and toggles the LED on pin 13.
*
* Modified from one by (cleft) 2005 D. Cuartielles for K3
*/
int ledPin = 13;
int knockSensor = 2;
byte val = 0;
int statePin = LOW;
int THRESHOLD = 1; // if it's too sensitive then change this value
void setup()
{
pinMode(ledPin, OUTPUT);
}
void loop()
{
val = analogRead(knockSensor);
if (val >= THRESHOLD) { // check the piezo
statePin = !statePin; // sets the pin to the opposite state
digitalWrite(ledPin, statePin); // turn on or off the LED
}
}
http://electronics.divinechildhighschool.org/Home/Arduino-Lessons/analog-read-and-a-piezo
Labels: Prototype7, TKLights
Post a Comment