Tilt Switch with LED Indicator and Fan Interrupt

This project was about making a tilt sense system that involves a motor or fan. The system is also programmed and set up with a tip sense light. It simulates a tip-over or roll-over situation and when the system reaches a 90-degree angle from level. At 90 degrees, the sensor drive signal shuts everything down through the Nano. It also has industrial applications as there are different tilt switches at different angles.

Tilt detection system that senses motion up to a 90 degree angle before motor or fan cut-off. The green LED indicator represents a normal state. While the red LED illumination represents an abnormal state when the system tilts 90 degrees or more.

Normal state of operation with function fan or motor.

Abnormal state of operation with fan interrupted.

Project Schematic:

The system requires separate power supplies to support a higher current draw motor or fan unless the entire system provides for sufficient power or current draw. Motors and fans normally draw much more current that the controller or sensor devices hosted within its system.

A tilt switch is really just a type of motion sensor that activates after a certain angle from a reference point is reached. Among various approaches toward level detection and sensor motion, this project uses a canister tilt switch that uses a small internal ball that interrupts a closed switch path as it is rolled from one position to another at the component’s specified angle.

At the specified angle, the tilt switch path is open and no further connection between its leads is permitted. For example, in a level state, a tilt device’s upright position settles an internal miniature metal ball for a closed switch path (or “on” function). Conversely, when the position tips beyond its specified angle, the internal metal ball moves to another position where the connection path between the two switch leads become interrupted (or “off” function).

Tilt switch canister with two leads and internal unseen miniature ball.

Project Operation:

The demonstration of this system zooms in on the states of LED illumination and fan movement as its position changes from level (0-degrees) to upright (90-degrees).


Code Setup:

int speedPin=5;
int dir1=4;
int dir2=3;
int mSpeed=255;
int tiltPin=2;
int tiltVal;

int redPin=7;
int greenPin=6;

void setup() {
Serial.begin(9600);
pinMode(speedPin,OUTPUT);
pinMode(dir1,OUTPUT);
pinMode(dir2,OUTPUT);
pinMode(tiltPin,INPUT);
digitalWrite(tiltPin,HIGH); //to assign as pullup pin

pinMode(redPin,OUTPUT);
pinMode(greenPin,OUTPUT);
}

void loop() {
digitalWrite(dir1,LOW);
digitalWrite(dir2,HIGH);
tiltVal=digitalRead(tiltPin);
Serial.println(tiltVal);
if (tiltVal==0){
digitalWrite(greenPin,HIGH);
digitalWrite(redPin,LOW);
analogWrite(speedPin,mSpeed);
}
if (tiltVal==1){
digitalWrite(greenPin,LOW);
digitalWrite(redPin,HIGH);
analogWrite(speedPin,0);
}
}


About

Servant of Christ Jesus. U.S. Military Veteran, Electrical Engineer, Pepperdine MBA, and M.A. Biblical and Theological Studies.

, ,

Comments are closed.