Tilt sensor with Arduino
Video-:
Materials Needed-:
- Arduino board
- Any color LED bulb
- TILT sensor
- Bread Board
- Buzzer
- Jumper wires(male to male and male to female)
Circuit Diagram-:
Code-:
#define TILT 2
#define LED 4
#define BUZZER 3
void setup() {
Serial.begin(9600);
pinMode(TILT, INPUT);
pinMode(LED, OUTPUT);
pinMode(BUZZER, OUTPUT);
}
void loop() {
int TILT_VALUE = digitalRead(TILT);
if (TILT_VALUE == LOW){
digitalWrite(LED,HIGH);
digitalWrite(BUZZER, HIGH);
}
else {
digitalWrite(LED,LOW);
digitalWrite(BUZZER, LOW);
}
}
0 Comments