Wednesday, December 16, 2009
Prototype #8
Description:
By bending the piezo tab back and forth we are now able read variable output values in the serial monitor in Arduino interface.
Input:
Piezo Film
Output:
Serial read of values in Arduino
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: Piezo, Prototype8, TKLights
Post a Comment