-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultiplevibrationsensors1.txt
23 lines (21 loc) · 1.1 KB
/
multiplevibrationsensors1.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
int vibpin1 = 8; //declaring the channel for input from first vibration sensor
int vibpin2 = 7; //declaring the channel for input from second vibration sensor
int vibpin3 = 12; //declaring the channel for input from third vibration sensor
int relaypin = 13;//setting the pin for
void setup() {
pinMode(vibpin1, INPUT); //setting up the channel for taking input signal
pinMode(vibpin2, INPUT); //setting up the channel for taking input signal
pinMode(vibpin3, INPUT); //setting up the channel for taking input signal
pinMode(relaypin, OUTPUT);//setting up the channel for sending output signal to relay
}
void loop() {
int vibSignal1 = digitalRead(vibpin1);//reads input from 1st vibration sensor
int vibSignal2 = digitalRead(vibpin2);//reads input from 2nd vibration sensor
int vibSignal3 = digitalRead(vibpin3);//reads input from 3rd vibration sensor
if(vibSignal1 == 1 || vibSignal2 == 1 || vibSignal3 == 1)
digitalWrite(relaypin, HIGH);//sends signal to relay to complete the circuit
delay(10000);
else
digitalWrite(relaypin, LOW);//sends signal to relay to break the circuit
delay(5000);
}