Tilt Sensor SW-520D

The “Tilt Sensor” is a device used for knowing the planar movement. Although they are available in various types their basic function remains the same. Their function is to detect the plane shift from horizontal to vertical and sent of a signal when it happens. There are modules which could sense even small plane shifts but here we are going to discuss about simple contact type Tilt module.  The Tilt Sensor number is SW-520D.

TILT SENSOR PIN ARDUINO CONNECTION
Digital Output Any Digital input of Arduino Uno
GND Ground
Vcc 5V DC

The tilt sensor is many times referred to as inclinometer, tilt switch or rolling ball sensor. Using a tilt sensor is a simple way to detect orientation or inclination. This makes it very useful to be used, for example, in toys, robots and other appliances whose working methodology depends on inclination.
WORKING DETAILS:
The tilt sensor is cylindrical and contains a free conductive rolling ball inside with two conductive elements (poles) beneath.
When the sensor is completely upright, the ball falls to the bottom of the sensor and connects the poles, allowing the current to flow.
When the sensor is tilted, the ball doesn’t touch the poles, the circuit is open, and the current doesn’t flow.
This way, the tilt sensor acts like a switch that is turned on or off depending on its inclination. So, it will give digital information to the Arduino, either an HIGH or a LOW signal.
SPECIFICATIONS:
1. Supply voltage: 3.3 V to 5V
2. Output can directly connected to controller
3. TTL level output
4. Maximum output current : 15mA
5. Can work on low voltages
6. Maximum operating temperature: 0°C to + 80°C
7. Easy interface
8. Long life.
APPLICATIONS:
1. Security systems.
2. Digital cameras
3. Toys
4. Motors
5. Robotic arms
6. Vending machines.
7. Measuring instruments.
8. Hobby projects.

ALL SENSOR DETAILS:
1. HC-05 – Bluetooth
2. Mpu 6050 accelerometer-gyroscope- -module
3. Flame-sensor
4. Rotary-encoder
5. Force-sensor-fsr400
6. Current-sensor-acs712
7. Flex-sensor
8. IR-sensor-tcrt5000
9. Pulse-sensor-pin
10. Color-sensor-tcs230
11. SD-card-module
12. Oled-with-arduino
13. Addressable-rgb-led-strip-ws1812
14. Relay-module
15. TFT-1-8-display-st7735r
16. 8×8-dot-matrix-display-max7219
17. Smoke-sensor-mq-2
18. Ultrasonic-sensor-HC-sr04
19. PIR-motion-sensor-hc-sr501
20. Tilt-sensor-sw-520d
21. Microphone-sound-sensor
22. Reed-switch-reed-sensor
23. Rfid-reader-Em18
24. Rfid-tag
25. RTC-real-time-clock-ds1307
26. Temperature-sensor-ds18b20
27. Moisture-sensor
28. Rain-sensor
29. Pressure-sensor
30. Accelerometer
31. MOC-3021-circuit
32. DHT11-DHT22-temperature-and-humidity-sensor
TILT SENSOR WITH ARDUINO UNO CIRCUIT DIAGRAM.
Wiring the tilt sensor to you Arduino is pretty straightforward. You just need to connect one pin to the Arduino digital pins.
If you connect the sensor like so, you need to activate the Arduino internal pull-up resistor for the digital pin to which your sensor is connected to. Otherwise, you should use a 10kOhm pull up resistor in your circuit.
TILT SENSOR WITH ARDUINO CODE:
Copy and paste or Download below given link
// Circuito.io is an automatic generator of schematics and code for off the shelf hardware combinations.
// Copyright (C) 2016 Roboplan Technologies Ltd.
// Include Libraries
#include “Arduino.h”
#include “LiquidCrystal.h”
#include “LED.h”
#include “Switchable.h”
#include “Button.h”
// Pin Definitions
#define LCD_PIN_RS 8
#define LCD_PIN_E 7
#define LCD_PIN_DB4 2
#define LCD_PIN_DB5 3
#define LCD_PIN_DB6 4
#define LCD_PIN_DB7 6
#define LEDR_PIN_VIN 5
#define TILTSWITCH_PIN_2 9
// Global variables and defines
// object initialization
LiquidCrystal lcd(LCD_PIN_RS,LCD_PIN_E,LCD_PIN_DB4,LCD_PIN_DB5,LCD_PIN_DB6,LCD_PIN_DB7);
LED ledR(LEDR_PIN_VIN);
Button TiltSwitch(TILTSWITCH_PIN_2);
// define vars for testing menu
const int timeout = 10000; //define timeout of 10 sec
char menuOption = 0;
long time0;
// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.
void setup()
{
// Setup Serial which is useful for debugging
// Use the Serial Monitor to view printed messages
Serial.begin(9600);
while (!Serial) ; // wait for serial port to connect. Needed for native USB
Serial.println(“start”);
// set up the LCD’s number of columns and rows
lcd.begin(16, 2);
TiltSwitch.init();
menuOption = menu();
}
// Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop.
void loop()
{
if(menuOption == ‘1’) {
// LCD 16×2 – Test Code
// Print a message to the LCD.
lcd.setCursor(0, 0);
lcd.print(“Circuito Rocks !”);
// Turn off the display:
lcd.noDisplay();
delay(500);
// Turn on the display:
lcd.display();
delay(500);
}
else if(menuOption == ‘2’) {
// LED – Basic Red 5mm – Test Code
// The LED will turn on and fade till it is off
for(int i=255 ; i> 0 ; i -= 5)
{
ledR.dim(i); // 1. Dim Led
delay(15); // 2. waits 5 milliseconds (0.5 sec). Change the value in the brackets (500) for a longer or shorter delay in milliseconds.
}
ledR.off(); // 3. turns off
}
else if(menuOption == ‘3’)
{
// Tilt Sensor – AT407 – Test Code
//Read Tilt Switch state.
//if Switch is tilted function will return HIGH (1). if not function will return LOW (0).
//for debounce funtionality try also TiltSwitch.onPress(), .onRelease() and .onChange().
//if debounce is not working properly try changing ‘debounceDelay’ variable in Button.h
bool TiltSwitchVal = TiltSwitch.read();
Serial.print(F(“Val: “)); Serial.println(TiltSwitchVal);
}
if (millis() – time0 > timeout)
{
menuOption = menu();
}
}
// Menu function for selecting the components to be tested
// Follow serial monitor for instrcutions
char menu()
{
Serial.println(F(“\nWhich component would you like to test?”));
Serial.println(F(“(1) LCD 16×2”));
Serial.println(F(“(2) LED – Basic Red 5mm”));
Serial.println(F(“(3) Tilt Sensor – AT407”));
Serial.println(F(“(menu) send anything else or press on board reset button\n”));
while (!Serial.available());
// Read data from serial monitor if received
while (Serial.available())
{
char c = Serial.read();
if (isAlphaNumeric(c))
{
if(c == ‘1’)
Serial.println(F(“Now Testing LCD 16×2”));
else if(c == ‘2’)
Serial.println(F(“Now Testing LED – Basic Red 5mm”));
else if(c == ‘3’)
Serial.println(F(“Now Testing Tilt Sensor – AT407”));
else
{
Serial.println(F(“illegal input!”));
return 0;
}
time0 = millis();
return c;
}
}
}
Download Tile Sensor Sketch Here Tilt_Sensor_with_lcd After Downloaded extract the open folder and double click the Arduino Uno code. Then compile and upload to Arduino board and test.

Subramanian
Subramanian

Subramanian MK, currently serving as a workshop instructor at Sakthi Polytechnic College, Erode Tamil Nadu. With a career spanning 25 + years, Subramanian MK has dedicated himself to advancing knowledge in Electronics and Communication Engineering (ECE). His passion for exploring new technologies has led to the development of numerous projects, showcasing expertise in IoT and PCB design.

Articles: 505

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

×

Hi, How can I help you?

×