When I tried to run serial printf on the bolean function below, if the state is false, the output isn't printing 0 but instead some random number. But, when the state is one, 1 is been printed. The bauld rate has been set to 9600.
This program suppose to read input from a motion sensor.
boolean sensor(){
Serial.begin (9600);
digitalRead (_sensorPin);
boolean state = true;
if (!digitalRead (_sensorPin)== HIGH){
boolean state = false;
}
boolean sensor(){
Serial.begin (9600);
digitalRead (_sensorPin);
boolean state = true; <<< one variable here
if (!digitalRead (_sensorPin)== HIGH){
boolean state = false; <<< another variable here
}
Serial.println (state);
return state;
}