Pages: [1]   Go Down
Author Topic: arduino + piezo sensor (once again ;)  (Read 655 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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

 pinMode(servoPin,OUTPUT);
  servo1.attach(servoPin);

 Serial.begin(9600);       // use the serial port
 Serial.print("los");
}

void loop() {

  sensorReading = analogRead(knockSensor);    

  if (sensorReading >= threshold) {
      digitalWrite(ledPin, HIGH);
      Serial.println(sensorReading);  
      servo1.write(40);    
  } else {
      servo1.write(0);
      digitalWrite(ledPin, LOW);
  }
   SoftwareServo::refresh();
  delay(100);  // delay to avoid overloading the serial port buffer
}
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

a picture of our setting - we tried to combine ten 10kOhm resistors in series to replace one 1mOhm resistor.

« Last Edit: December 08, 2010, 09:17:57 am by slash » Logged

UK
Offline Offline
Faraday Member
**
Karma: 17
Posts: 2884
Gorm deficient
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ten 10kohm resistors in series is 100kohm, not 1 milliohm.
That's a huge difference.
Logged

Per Arduino ad Astra

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-wink ?
« Last Edit: December 08, 2010, 09:24:38 am by slash » Logged

Humboldt, CA
Offline Offline
Full Member
***
Karma: 2
Posts: 223
Arduino BBB
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: