Hi,
The below first sketch works but the second (which is a modification of the first), doesn’t.
I cannot understand why the Boolean function isn’t returning the correct state.
The idea behind it is the turn on the led when motion is detected by the sensor.
Any help is appreciated.
TIA
const int ledPin = 13;
const int vibroPin = 3;
void setup() {
pinMode(vibroPin, INPUT);
pinMode(ledPin, OUTPUT); // test use only
}
void loop() {
vibrationCheck ();
}
void vibrationCheck() {
long measurement;
measurement = pulseIn (vibroPin, HIGH); //wait for the pin to get HIGH and returns measurement
if (measurement > 1000) digitalWrite(ledPin, HIGH);
else digitalWrite(ledPin, LOW);
delay(50);
}
const int ledPin = 13;
const int vibroPin = 3;
void setup() {
pinMode(vibroPin, INPUT);
pinMode(ledPin, OUTPUT); // test use only
}
void loop() {
if (vibrationCheck) digitalWrite(ledPin, HIGH);
else digitalWrite(ledPin, LOW);
}
bool vibrationCheck() {
long measurement;
measurement = pulseIn (vibroPin, HIGH); //wait for the pin to get HIGH and returns measurement
if (measurement > 1000) return true;
else return false;
delay(50);
}