siteswapjuggler
Member
Hi there,
this is my first post so please forgive my lack of knowledge here. I use to program a lot with Arduino and Teensy for various projects but in some way I miss some basics. Recently I came back to a project where I use Piezo sensor to detect the position of impacts on a floor. I started back from the very beginning and came across a very strange behavior with a Teensy 3.1 and the analogRead() function.
For now I'm just trying to get the sensor value here is the schematics
and the code :
The problem is that I never get a value of 0. Dispite it works well with an Arduinon Uno, I got values around 15 instead with the Teensy board.
Even with the A0 pin connected directy to the ground I got a value of 1 with the Teensy board...
I don't understand why so any help will be welcome.
Thanks, Sylvain
this is my first post so please forgive my lack of knowledge here. I use to program a lot with Arduino and Teensy for various projects but in some way I miss some basics. Recently I came back to a project where I use Piezo sensor to detect the position of impacts on a floor. I started back from the very beginning and came across a very strange behavior with a Teensy 3.1 and the analogRead() function.
For now I'm just trying to get the sensor value here is the schematics
and the code :
Code:
#include <Metro.h>
#define INPIN A0
int sensorValue = 0;
Metro myMetro = Metro(1000);
void setup() {
Serial.begin(115200);
}
void loop() {
int tmp = analogRead(INPIN);
if ( tmp > sensorValue) sensorValue = tmp;
if (myMetro.check()) {
Serial.println(sensorValue);
sensorValue = 0;
}
}
The problem is that I never get a value of 0. Dispite it works well with an Arduinon Uno, I got values around 15 instead with the Teensy board.
Even with the A0 pin connected directy to the ground I got a value of 1 with the Teensy board...
I don't understand why so any help will be welcome.
Thanks, Sylvain