Dear All :
I have been looking around the forum for a solution, but haven't found. I have one Adruino uno, three door/window sensors , one buzzer sensor. One door sensor will be on my apartment front door, one door sensor will be on my bathroom door, one sensor will on window.
The problem is that I don't know how to make the three sensor works independently? when someone open the door or window, the buzzer should be trigger and the Computer will show"Door 1/2 is opening" or "window is opening ".
Now the three sensor is series. The code is that:
const int buzzer = 3;
const int sensor = 4;
int state; // 0 close - 1 open wwitch
void setup()
{
pinMode(sensor, INPUT_PULLUP);
}
void loop()
{
state = digitalRead(sensor);
if (state == HIGH){
tone(buzzer, 400);
}
else{
noTone(buzzer);
}
delay(200);
}
What i am trying to do is have 3 door sensors running from one arduino uno as they will be in different door. I realise that this is probably some thing but how would i go about changing the code to make this happen?
I appreciate any help. Thanks
Best Regrads;