SW-520D Tilt Sensor Module

25,00 DH 30,00 DH

Availability:

157 in stock

SKU: 0150 Categories: ,

Description

SW-520D Tilt Sensor Module

The SW-520D tilt sensor module detects tilt or orientation. It uses a metal-ball switch to detect changes in plane, moving from horizontal to vertical and vice versa. The module provides both digital and analog outputs for flexible use.

Detailed specifications

  • Supply voltage: 3.3–5 V
  • Digital output: 0 or 1
  • Analog output: Voltage proportional to the tilt angle
  • Maximum output current: 15 mA
  • Operating temperature: 0°C to +80°C
  • Service life: Long

How it works

The SW-520D module contains two metal balls that make electrical contact when tilted. In the horizontal position, the balls do not touch the internal terminals, creating an open circuit. In the vertical position, the balls touch the terminals, creating a closed circuit and triggering a digital signal. The analog output varies with the tilt angle.

Applications

  • Security systems
  • Digital cameras
  • Toys
  • Robotic arms
  • Vending machines
  • Measuring instruments
  • Hobby projects

Pinout

  • VCC: Power supply (3.3–5 V)
  • GND: Ground
  • DO: Digital output
  • AO: Analog output

Using it with an Arduino Uno

Basic Arduino code example

const int sensorPin = 3;
int sensorState = 0;


void setup() {
  Serial.begin(9600);
  pinMode(sensorPin, INPUT);
}


void loop() {
  sensorState = digitalRead(sensorPin);
  if (sensorState == HIGH) {
    Serial.println("Inclinaison détectée");
  } else {
    Serial.println("Pas d'inclinaison");
  }
  delay(100);
}

What the code does: It reads the tilt sensor’s digital value and displays its state in the serial monitor.

Components required for the basic example

  • Arduino Uno
  • SW-520D module
  • Connecting wires

Basic code explained

  1. Initialization: Serial communication is started in setup().
  2. Reading and displaying data: Sensor values are read and displayed in the serial monitor.

Basic wiring

  • VCC (SW-520D): 5 V (Arduino)
  • GND (SW-520D): GND (Arduino)
  • DO (SW-520D): D3 (Arduino)

Advanced Arduino code example

#include <Wire.h>
#include <LiquidCrystal_I2C.h>


LiquidCrystal_I2C lcd(0x27, 16, 2);
const int sensorPin = 3;
int sensorState = 0;


void setup() {
  lcd.begin();
  lcd.backlight();
  Serial.begin(9600);
  pinMode(sensorPin, INPUT);
}


void loop() {
  sensorState = digitalRead(sensorPin);
  if (sensorState == HIGH) {
    lcd.setCursor(0, 0);
    lcd.print("Inclinaison detectee");
    Serial.println("Inclinaison détectée");
  } else {
    lcd.setCursor(0, 0);
    lcd.print("Pas d'inclinaison ");
    Serial.println("Pas d'inclinaison");
  }
  delay(100);
}

What the code does: It reads the tilt sensor’s digital value and displays it on an I2C LCD and in the serial monitor.

Components required for the advanced example

  • Arduino Uno
  • SW-520D module
  • 1602 I2C LCD
  • Connecting wires

Advanced code explained

  1. Including libraries: #include <Wire.h> and #include <LiquidCrystal_I2C.h> add the libraries required for the LCD.
  2. Initialization: Communication with the LCD is set up in setup().
  3. Reading and displaying data: The sensor values are read and displayed on the LCD and in the serial monitor.

Advanced wiring

  • VCC (SW-520D): 5 V (Arduino)
  • GND (SW-520D): GND (Arduino)
  • DO (SW-520D): D3 (Arduino)
  • VCC (LCD): 5 V (Arduino)
  • GND (LCD): GND (Arduino)
  • SCL (LCD): A5 (Arduino)
  • SDA (LCD): A4 (Arduino)

Installing the driver/library

To use the SW-520D sensor and LCD with Arduino, install the LiquidCrystal I2C library through the Arduino IDE:

  1. Open the Arduino IDE: Make sure you are using the latest version.
  2. Open the Library Manager: From the menu, choose Sketch → Include Library → Manage Libraries.
  3. Search for “LiquidCrystal I2C”: Use the search box to find the library.
  4. Install the library: Click Install to add it to your IDE.

Keywords: tilt, sensor, shaking, vibration.

Thank you for your loyalty!

EN