sensor-experiments

Objective

This experiment uses a tilt sensor to detect changes in the angle of a surface or device.

Required Components

No Ads Available.

Working Principle

The tilt sensor works by detecting changes in the orientation of the sensor. When tilted, the internal switch is triggered.

Arduino Code


/*
 * Tilt Detection with Tilt Sensor
 * This code reads the tilt status from the sensor and prints the result.
 */

const int tiltPin = 2;  // Tilt sensor connected to digital pin 2
int tiltState = 0;

void setup() {
    pinMode(tiltPin, INPUT);
    Serial.begin(9600);  // Initialize serial communication
}

void loop() {
    tiltState = digitalRead(tiltPin);  // Read the sensor value
    if (tiltState == HIGH) {
        Serial.println("Tilt Detected");
    } else {
        Serial.println("No Tilt");
    }
    delay(1000);  // Wait for 1 second before the next reading
}
            

Results

The serial monitor will display either "Tilt Detected" or "No Tilt" based on the sensor's orientation.

Applications

  • Device orientation detection
  • Security systems (e.g., theft detection)
  • Robot navigation

Conclusion

The tilt sensor provides a simple way to detect changes in orientation, making it suitable for a wide range of applications, including security and robotics.

Contact Us

If you have any questions or inquiries, feel free to reach out to us at Microautomation.no@icloud.com .

Follow our Socials for the newest updates!