ARDUINO TUTORIAL FOR BEGINNERS LESSON 6: LEARN HOW TO USE TILT SWITCH
In this lesson, we are going to learn how to use a tilt switch with the use of Arduino Uno Board. This Arduino tutorial for beginners will let you learn the basic of tilt switch.
#ArduinoUno #TiltSwitch #ArduinoTiltSwitch
ARDUINO TUTORIAL FOR BEGINNERS LESSON 6: LEARN HOW TO USE TILT SWITCH
In this lesson, we are going to learn how to use a tilt switch with the use of Arduino Uno Board. This Arduino tutorial for beginners will let you learn the basic of tilt switch.
Reference: https://www.makerlab-electronics.com/
Introduction
The tilt switch used here is a ball one with a metal ball inside. It is used to detect small angle of inclination.
Components
- 1 * Arduino Uno board
- 1 * USB data cable
- 1 * Tilt switch
- Several jumper wires
Experimental Principle
The principle is very simple. When the switch is tilted in a certain angle, the ball inside rolls down and touches the two contacts connected to the pins outside, thus triggering circuits. Otherwise the ball will stay away from the contacts, thus breaking the circuits.
Experimental Procedures
Step 1: Build the circuit
The schematic diagram
Step 2: Program (Please refer to the example code)
Step 3: Compile the code
Step 4: Upload the sketch to the Arduino Uno board
Now, tilt the switch, and the LED attached to pin 13 on Arduino Uno board will light up.
Arduino Code:
//tilt switch //tilt the switch, and the LED attached to pin 13 on SunFounder Uno board will light up. //tilt switch attach to pin2 /*****************************************/ const int ledPin = 13;//the led attach to void setup() { pinMode(ledPin,OUTPUT);//initialize the ledPin as an output pinMode(2,INPUT);//set pin2 as INPUT digitalWrite(2, HIGH);//set pin2 as HIGH } /******************************************/ void loop() { int digitalVal = digitalRead(2);//Read the value of pin2 if(HIGH == digitalVal)//if tilt switch is not breakover { digitalWrite(ledPin,LOW);//turn the led off } else ////if tilt switch breakover { digitalWrite(ledPin,HIGH);//turn the led on } } /**********************************************/
Related searches: tilt switch arduino,tilt switch sensor,mercury tilt switch,arduino,arduino uno,arduino tutorial,tilt switch,tilt switch project,tilt switch module,tilt switch module arduino,tilt switch uses,tilt switch arduino code,tilt switch application,tilt switch example,tilt switch function,tilt switch sensor working,tilt switch working principle,arduino tilt ball switch,arduino tilt switch,arduino tilt switch project,arduino tilt switch code,tilt switch tutorial
Join this channel to get access to perks: https://www.youtube.com/channel/UCEoNaDH6R_Iu8ee58-hsGxQ/join
Follow our social media accounts:
Facebook: https://www.facebook.com/kringgidz
Facebook: https://www.facebook.com/gideongasulasbuniel
Website: https://e-boombots.com/
Instagram: https://www.instagram.com/gideongbuniel/
Twitter: https://twitter.com/KringxG
Tumbler: https://www.tumblr.com/blog/kringxgidz
Pinterest: https://www.pinterest.ph/KringxGidz
Linkedin: https://www.linkedin.com/in/gideon-buniel-118bb35a/
Full Video: