Go Down

Topic: arduino + piezo sensor (once again ;) (Read 1 time) previous topic - next topic


hey guys,
we're trying to get the piezo sensor work correctly. we used the tutorial on the arduino website.

if we open the Serial Monitor, it looks like the value of the piezo sensor is counting down from 1000 to 0. if we hit it, it snaps to 400 for example and goes down slowly to 0 again.

can you give us a hint? would be great.
kind regards, lisa & tobi

Code: [Select]

#include <SoftwareServo.h>

int servoPin = A5;      // the servos is connected to analog pin 5
int knockSensor = A0; // the piezo is connected to analog pin 0
int threshold = 700;  // threshold value to decide when the detected sound is a knock or not
SoftwareServo servo1;
int ledPin = 13;      // led connected to digital pin 13

// 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() {

 sensorReading = analogRead(knockSensor);    

 if (sensorReading >= threshold) {
     digitalWrite(ledPin, HIGH);
 } else {
     digitalWrite(ledPin, LOW);
 delay(100);  // delay to avoid overloading the serial port buffer


Dec 08, 2010, 03:15 pm Last Edit: Dec 08, 2010, 03:17 pm by slash Reason: 1
a picture of our setting - we tried to combine ten 10kOhm resistors in series to replace one 1mOhm resistor.


Ten 10kohm resistors in series is 100kohm, not 1 milliohm.
That's a huge difference.
Some people are like Slinkies.

Not really good for anything, but they bring a smile to your face when pushed down the stairs.


Dec 08, 2010, 03:22 pm Last Edit: Dec 08, 2010, 03:24 pm by slash Reason: 1
ahhhh. nooooo. thanks a lot groove! so we need to get a 1mOhm resistor. or is there a possibility to get more ot of ten 10kOhm resistors ;) ?


If you need a megaohm resistor you'll need 100 of the 10kOhm flavor.  I'd hit radioshack or somesuch and pick up the proper resistor, personally.

Go Up