Ive got some Guitar hero drum pads with basic Piezo sensors in them, (I did a very similar project last year and had no issues) however when I hook these up I dont the stream of numbers I am used to seeing in my serial monitor; It seems to read the analog Pin number associated with whatever pin im on....Ive switched arduinos and resistors and tried all three drum pads. With the same result.....any ideas?
Here is an idea: post your code, using code tags, and a wiring diagram.
*/
// these constants won't change:
const int ledPin = 13; // led connected to digital pin 13
const int knockSensor = A0; // the piezo is connected to analog pin 0
const int threshold = 100; // threshold value to decide when the detected sound is a knock or not
// these variables will change:
int sensorReading = 0; // variable to store the value read from the sensor pin
int ledState = LOW; // variable used to store the last LED status, to toggle the light
void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as as OUTPUT
Serial.begin(9600); // use the serial port
}
void loop() {
// read the sensor and store it in the variable sensorReading:
sensorReading = analogRead(knockSensor);
Serial.println(knockSensor); // print the sensor value in the serial moniter
// if the sensor reading is greater than the threshold:
if (sensorReading >= threshold) {
// toggle the status of the ledPin:
ledState = !ledState;
// update the LED pin itself:
digitalWrite(ledPin, ledState);
// send the string "Knock!" back to the computer, followed by newline
Serial.println("Knock!");
}
delay(100); // delay to avoid overloading the serial port buffer
}
wiring diagram
black wire from Piezo to ground
red wire to Pin A0
1 M ohm resistor connecting red and black wire
sorry
ZhouXe:
It seems to read the analog Pin number associated with whatever pin I'm on....
Change:
Serial.println(knockSensor);
to:
Serial.println(sensorReading);
facepalm