hoogli
1
Can anyone help me solve this i am using a tilt sensor
int soundSensor =3;
int LED =2;
void setup()
{
Serial.begin(2000000);
pinMode (soundSensor, INPUT);
pinMode (LED, OUTPUT);
}
void loop()
{
Serial.println(soundSensor);
int statusSensor = digitalRead (soundSensor);
delay(1000);
if (statusSensor == 5)
{
digitalWrite(LED, HIGH);
}
else
{
digitalWrite(LED, LOW);
}
}
6v6gt
2
Don't confuse the pin number with the value returned when reading the pin.
hoogli
3
the value does not change even if i tilt the sensor
LarryD
4
Serial.println(soundSensor);
Serial.println(digitalRead(soundSensor));
LarryD
5
Depending on how you wire your sensor:
pinMode (soundSensor, INPUT);
verses
pinMode (soundSensor, INPUT_PULLUP);
system
Closed
7
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.