arduino counter using IR sensor FC-51 is for use at bathroom or toilet
for counting people in and out, if the counter is zero, then it will turn off the light
#define in 5
#define out 7
#define relay 2
#define power 9
int pinIn;
int pinOut;
int statusIn= 0;
int statusOut;
int count=0;
void IN()
{
count++;
//Serial.println(count);
delay(1000);
}
void OUT()
{
count--;
//Serial.println(count);
delay(1000);
}
void setup()
{
Serial.begin(9600);
delay(2000);
pinMode(in, INPUT);
pinMode(out, INPUT);
pinMode(relay, OUTPUT);
pinMode(power, OUTPUT);
digitalWrite(power, HIGH);
}
void loop()
{
Serial.println(count);
//ada halangan 0
pinIn = digitalRead(in);
if(statusIn == 0 && pinIn == 0 && pinOut == 0){
IN();
statusIn = 1;
}
if(statusIn == 1 && pinIn == 1){
statusIn =0;
}
pinOut = digitalRead(out);
if(statusOut == 0 && pinOut == 0 && pinIn == 0){
OUT();
statusOut = 1;
}
if(statusOut == 1 && pinOut == 1){
statusOut =0;
}
}
================================
arduino bathroom ligh saving
arduino on off bathroom light
arduino automatic switch off bathroom if no people inside
lampu toilet otomatis
contact : veluska@gmail.com (at indonesia-jakarta)