Wednesday, December 16, 2009
Prototype #9
Description:
As the Piezo tab is bent, the Piezo element buzzer produces a tone that increases with the amount of force applied to the tab.

Input:
Piezo tab
Output:
Piezo buzzer
Setup:
Result:
Code:
int analogPin = 3; // potentiometer wiper (middle terminal) connected to analog pin 3 // outside leads to ground and +5V
int ledPin = 13; // LED connected to digital pin 9
int val = 0; // variable to store the value read
void setup()
{
Serial.begin(9600); // setup serial
pinMode(ledPin, OUTPUT); // sets the pin as output
}
void loop()
{
val = analogRead(analogPin)/4; // read the input pin
Serial.println(val); // debug value
val = analogRead(analogPin); // read the input pin
digitalWrite(ledPin, val / 4); // analogRead values go from 0 to 1023, analogWrite values from 0 to 255
}
int ledPin = 13; // LED connected to digital pin 9
int val = 0; // variable to store the value read
void setup()
{
Serial.begin(96
pinMode(ledPin, OUTPUT); // sets the pin as output
}
void loop()
{
val = analogRead(anal
Serial.println(
val = analogRead(anal
digitalWrite(le
}
Labels: Prototype #9, TKLights
Post a Comment