(for example A0) on the Arduino you can expect to read a value of 0 (0V) when in its upright position and 1023 (5V) when it is tilted.

Similar documents
Tilt Sensor. Created by lady ada. Last updated on :04:38 PM UTC

Temperature Sensor. Positive + (to 5 volts.) Ground. To A0 To GND Signal. To 5v

SM361 RIG SWITCH CONSTRUCTION MANUAL

EGG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

EGG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

The Easy Driver gives you the capability to drive bipolar stepper motors between 150mA to 700mA per phase.

8 Channel 5V Optical Isolated Relay Module

Bill of Materials: Car Battery/charging system diagnostics PART NO

1 Introduction. 2 Cranking Pulse. Application Note. AN2201/D Rev. 0, 11/2001. Low Battery Cranking Pulse in Automotive Applications

IFC-BL02 Interface Free Controller Brushless Motor Card

Silvertel. Ag Features. Multi-Stage Charging. Battery Reversal Protection. Reduced Power Consumption. Wide DC or AC Input Voltage Range

Nickel Cadmium and Nickel Hydride Battery Charging Applications Using the HT48R062

HDS 5105 Amplified pressure sensor/switch

A14-18 Active Balancing of Batteries - final demo. Lauri Sorsa & Joonas Sainio Final demo presentation

ELM327 OBD to RS232 Interpreter

PARTS LIST. Beams: 72x. 16x. 64x. 16x. 12x. 2x Breadboards CYB x TotemDuino 1x LabBoard 1x 30cm 34way Flat Cable 1x Power Supply 12v 1,5A

The CMPE 118 Cockroach Robot Dept. of Computer Engineering, UCSC

ZTP-101L (Part No : )

To put integrity before opportunity To be passionate and persistent To encourage individuals to rise to the occasion

Lesson 1 - Make The Car Move Points of this section

MAP Sensor. Technical Spec COPY RIGHTS ECOTRONS ALL RIGHTS RESERVED ECOTRONS LLC. -Manifold Absolute Pressure Sensor

ALTRONIC, INC. 712 TRUMBULLAVE. GIRARD, OHIO DIS. IGNITION SYSTEM 500 SERIES IMPORTANT SAFETY NOTICE

Frequently Asked Questions

Load Cell Amplifier HX711 Breakout Hookup Guide

Hybrid Off Grid Solar UPS

Build Manual. for Studying Electrical Conductivity using a 3D Printed 4-Point Probe Station

User's Manual. May 2013 V1.0. ROBOT. HEAD to TOE Product User s Manual HC SR04 Ultrasonic Sensor

RB-See-218. Seeedstudio Solar Charger Shield for Arduino V2. Introduction

Force Sensitive Resistor (FSR) Created by Ladyada

FireBeetle Covers-DC Motor & Stepper Driver SKU:DFR0508

Welcome to ABB machinery drives training. This training module will introduce you to the ACS850-04, the ABB machinery drive module.

1. Overview Power output & conditioning 5 2. What is included Software description 6 3. What you will need 2

Practical Issues Concerning Dispensing End Effectors Time Pressure

1.0 Features and Description

Self-Adjusting Hall Effect Gear Tooth Sensor IC CYGTS9802 with Complementary Output

Chapter 2. Battery Charger and Base Assembly

SUPERCAPACITOR BASED ENERGY STORAGE MODULE

STR3. Step Motor Drive. User Manual

Setup and Programming Manual

System Integration of an Electronic Monitoring System in All-Terrain Vehicles

Build Instructions and User Guide

Installation and Maintenance Instructions. World Leader in Modular Torque Limiters. PTM-4 Load Monitor

SR3-mini. Step Motor Drive User Manual. AMP & MOONS Automation

IV-3 VFD Shield for Arduino. Assembly Manual

Pressure and presence sensors in textile

Product Guide: Series III Pump Control Board Set (RoHS)

Silvertel. Ag Features. Multi-Stage Charging. Battery Reversal Protection. Reduced Power Consumption. Wide DC or AC Input Voltage Range

Automated Seat Belt Switch Defect Detector

BATTERY BOOSTER SHIELD

80V 300Ah Lithium-ion Battery Pack Data Sheet

Mercury VTOL suas Testing and Measurement Plan

Causes and Symptoms of Roll Feed Length Inaccuracy

ARDUINO 2WD SMART ROBOT CAR KIT

CCPM manager. A real alternative to expensive in-transmitter mixing

User Guide. Panel Mount Digital Tachometer. Model Washington Street Melrose, MA Phone Toll Free

18 October, 2014 Page 1

Energy Shield. Features. Specifications. Min Typical Max Unit voltage V current 5 / 750 ma

Accurate measurement of compressed air consumption and detection of leaks. Measuring the individual consumption per customer / cost centre

New System of Controlling Electric Car Using Concept of Accelerometer

Driver Board User Manual

Blancett Flow Meters A Division of Racine Federated Inc. 100 East Felix Street South, Suite 190 Fort Worth, Texas FAX:

THREE PHASE FAULT ANALYSIS WITH AUTO RESET ON TEMPORARY FAULT AND PERMANENT TRIP OTHERWISE

Autonomously Controlled Front Loader Senior Project Proposal

S 5.5V to 18V Operating Voltage Range S Up to 60V Fault Protection S Features Two On-Board 2-Wire Hall-Effect Sensors

Project Report EMF DETECTOR

ELM327 OBD to RS232 Interpreter

DIAMOND POINT VIBRATING PROBES

Kelly KDHA High Voltage Series/PM Motor Controller User s Manual

Kelly HSR Series Motor Controller with Regen User s Manual V 3.3. Kelly HSR Opto-Isolated Series Motor Controller with Regen.

INTRODUCTION. Specifications. Operating voltage range:

MAGPOWR Spyder-Plus-S1 Tension Control

Maglev Plus System. 1. Description

BUMP AND SPIN KIT ESSENTIAL INFORMATION. Version 1.0 PROGRAM AND DESIGN YOUR OWN BUGGY WITH THIS

Build your own omni robot

Digital Automatic. Accurate Measurement of On/Off Time for b/g WLAN/WiMAX LNAs LNA ON/OFF TIME. This article compares two

P1110-EVAL-PS. PowerSpot RF Wireless Power Development Kit for Battery Recharging. User Manual

TECHNICAL MANUAL FOR ELECTRONIC SPEEDOMETER STR-RIEJU MATRIX 2

Standalone Linear Li-Ion Battery Charger with Thermal Regulation

KIT Parking Sensor 814

three different ways, so it is important to be aware of how flow is to be specified

IDL Dragonfly Manual

Magnetic Alarm Switches

TB6612FNG Hookup Guide

User's Manual O

ACT V/1.5A Backup Battery Pack Manager FEATURES APPLICATIONS GENERAL DESCRIPTION. Rev 0, 06-Nov-13 Product Brief

International Journal of Advance Engineering and Research Development

How Does A Dc Cdi Ignition System Work >>>CLICK HERE<<<

Please Handle Carefully!

HM5061 Max.1.6A Li-ion Switching Charger IC

Table 1: 2-pin Terminal Block J1 Functional description of BSD-02LH Module Pin # Pin Description Table 2: 10-pin Header J2 Pin # Pin Description

SCHNITZ MOTORSPORTS USER MANUAL AND INSTALLATION GUIDE PRO-MOD BATTERY VOLTS DIAGNOSTICS NOS PULSE FREQUENCY NOS DELAY TIME IN SECONDS

Linear & Rotary Actuators F-41

G-0-10, Plaza Damas, Sri Hartamas KL Malaysia Tel: Fax:

Speed Gate ST-01. Double-Sided Section STD-01 ASSEMBLY AND OPERATION MANUAL

Freescale Semiconductor, I

Final Report 4/25/12. Project: Intelli-Shade. Team: Test Curtains Please Ignore

TomTom-Tools GmbH Wiesenstrasse Baden Switzerland. Phone 1: Phone 2: VAT ID:

control systems Made in Italy Integrated systems for the web tension regulation

RAIN SENSING AUTOMATIC CAR WIPER

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT DC1259A BATTERY BACKUP MANAGER BOARD

Transcription:

Tilt Sensor Module Tilt sensors are essential components in security alarm systems today. Standalone tilt sensors sense tilt angle or movement. Tilt sensors can be implemented using mercury and roller ball technology, and can be mounted using mechanical threading, magnets, or adhesives, depending on what type of surface they are being mounted to. Recent technological advancements in the manufacturing of tilt sensors have improved accuracy, reduced cost, and increased lifetime. The type SW-520D is a commonly available roller-ball type tilt sensor consists of two conductive elements (poles) and a conductive free mass (rolling ball), encapsulated in the same case. When the tilt sensor is oriented so that that end is downwards, the mass rolls onto the poles and shorts them, acting as a switch stroke. Microcontroller-compatible tilt sensor modules based on SW-520D are also available at affordable costs. Electronics circuitry behind this tiny module is usually centered around the dual- comparator chip LM393. The module features a tilt sensor, a signal amplifier, a standard 3-pin header, a power indicator that signals that the module is correctly powered, and a status indicator that lights up when a tilt is detected by the tilt sensor. When the tilt sensor is in its upright position, the ball inside the tilt sensor bridges the two contacts, completing the circuit. When the board is tilted, the ball moves, and the circuit opens. When upright, the module outputs 0V (L) and when it is tilted, it outputs 5V (H) through the digital output (DO) terminal of the 3-pin header. If the analog output (AO) of the module is connected to an analog input

(for example A0) on the Arduino you can expect to read a value of 0 (0V) when in its upright position and 1023 (5V) when it is tilted. Description: - Adopts high sensitivity ball switch SW-520D angle sensor - comparator output,high drive ability,over 15ma current - working voltage:3.3v-12v - with screw mounting hole - PCB size:4.2cm x 1.4cm - Adopts LM393 comparator Hook Up The tilt sensor module can be connected to arduino using suitable jumper wires. First of all connect the power supply lines; VCC and GND of the module to 5V and GND of the Arduino respectively. Next link the digital output (DO) of the module to digital pin 2 (D2) and analog output (AO) to analog input 0 (A0) of the arduino. The whole hardware should be powered by a 9V DC / USB source through the DC IN /USB socket of the Arduino board. Keep the tilt switch position in upright position as indicated in the figure shown below.

Sketch: Digital This example code wakes the onboard indicator (LED at D13) of the Arduino when a tilt is inputted by the tilt sensor module through the occupied digital input (D2). Just copy-paste this code into your Arduino IDE, compile, and upload it to your Arduino as usual. 1. const int statusled = 13; 2. const int switchtilt = 2; 3. int val = 0; 4. void setup(){ 5. pinmode (statusled,output); 6. pinmode (switchtilt,input); 7. } 8. void loop(){ 9. val = digitalread(switchtilt); 10. if (val == HIGH){ 11. digitalwrite(statusled,high); 12. } 13. else { 14. digitalwrite(statusled,low); 15. } 16. } Note that this code does not include a software-debounce feature commonly used with button/switch inputs. This is not necessary here because the tilt sensor module have a built-in (1ms) hardware debounce arrangement using a simple RC network (R-10K & C-100n).

Sketch: Analog This example code lights up the onboard indicator (LED at D13) of the Arduino when a tilt is inputted by the tilt sensor module through the occupied analog input (A0). Again, copy-paste this code into your Arduino IDE, compile, and upload it to your Arduino as done earlier. 1. int lightpin = 13; 2. int tiltpin = 0; 3. void setup() { 4. } 5. void loop() { 6. int analogvalue = analogread(tiltpin); 7. if (analogvalue<512) { 8. analogwrite(lightpin, 0); 9. } 10. else { 11. analogwrite(lightpin, analogvalue); 12. delay(1000); 13. } 14. } Many readers might wonder why I opted for somewhat strange sketches here. It s for nothing; first of all test your hardware with the included sketches, and then start the brainstorming. Replace the above described sketches with your own favourite sketches merely a little home work for you!

Frankly speaking, with the sketches presented here, these experiments can also be conducted using a tilt sensor (SW-520D) only, ie. without the whole tilt sensor module. If you have an independent tilt sensor component at hand, make a try with the following hardware instead of the dedicated module. Sketch: Interrupts Interrupt incorporated since the 0007 version of the Arduino IDE breaks in in the execution of the main code. On the hardware front, Arduino is equipped with two interrupt ports so Arduino can sense those pins for an event to wake up and resume execution of code. It is even possible to execute special code depending on which pin triggered the wake up (the interrupt). In short, interrupt is a method by which a microcontroller can execute its normal program while continuously monitoring for some kind of interrupt (event). This interrupt can be triggered by some sort of sensor, or input like a switch. When the interrupt occurs, the microcontroller takes immediate notice, saves its execution state, runs a small chunk of code often called the interrupt handler or interrupt service routine, and then returns back to whatever it was doing before. The set up in the program defines where the microcontroller should start executing code if a particular interrupt occurs. In Arduino, we use a function called attachinterrupt() to do this. This function adopts three parameters. The first is the number of the interrupt, which tells the microprocessor which pin to monitor. The second parameter of this function is the location of code we want to execute if this interrupt is triggered. And the third, tells it what type of trigger to look for, a logic high, a logic low or a transition between the two. You can find detailed articles/tutorials on Arduino Interrupts (prepared by me) elsewhere in this website. Following is a basic example sketch to demonstrate the interrupt function in an Arduino connected with the tilt sensor. This code looks for interrupts on interrupt pin 0 (D2) of the Arduino to control the onboard indicator at its output (D13). 1. #define LED_PIN 13 2. #define INTERRUPTPIN 0 3. volatile boolean state = HIGH; 4. void setup() { 5. pinmode(led_pin, OUTPUT); 6. attachinterrupt(interruptpin, inputchange, CHANGE); 7. } 8. void loop() { 9. digitalwrite(led_pin, state); 10. } 11. void inputchange()

12. { 13. state =!state; 14. } Unfortunately, this loose sketch is prone to mischief because of the switch-bounce problems. Replacing the 100nF capacitor (C) with a 1uF capacitor might solve this to a certain extent (hardware-debounce). Otherwise opt for a sketch filled with debounce code lines (software-debounce). You can see just how much bouncing occurs in this oscillogram of the input from a switch. Trace A is the voltage appearing at the input pin of the Arduino. Instead of the expected smooth transition, a series of pulses lasting over 1 ms are generated. Each one of these pulses would generate an (unnecessary) interrupt. However, if we attach some debouncing hardware to the switch then the bouncing effect is filtered out. Notice how the A trace is a smooth curve, with a gradual transition!