El sensor de inclinación es un interruptor de inclinación digital. Se puede utilizar como un simple sensor de inclinación. Simplemente conéctelo a nuestro escudo IO / Sensor; Usted puede hacer increíbles proyectos interactivos. Con escudo de sensor dedicado y Arduino, puede lograr un trabajo interesante e interactivo.
CARACTERÍSTICAS
Voltaje de suministro: 3.3V to 5V
Interfaz: Digital
Tamaño: 30 * 20m m
Peso: 3g
DIAGRAMA DE CONEXIÓN
CÓDIGO BÁSICO DE PRUEBA
int ledPin = 13; // Connect LED to pin 13
int switcher = 3; // Connect Tilt sensor to Pin3
void setup()
{
pinMode(ledPin, OUTPUT); // Set digital pin 13 to output mode
pinMode(switcher, INPUT); // Set digital pin 3 to input mode
}
void loop()
{
if(digitalRead(switcher)==HIGH) //Read sensor value
{
digitalWrite(ledPin, HIGH); // Turn on LED when the sensor is tilted
}
else
{
digitalWrite(ledPin, LOW); // Turn off LED when the sensor is not triggered
}