#define sensor1 4
#define sensor2 5
#define sensor3 6
#define beklet_sensor2 7
#define beklet_sensor3 8
#define alarm 10
#define akuled 11
int durum_sensor1 = 1;
int durum_sensor2 = 1;
int durum_sensor3 = 1;
int durum_beklet_sensor2 = 0;
int durum_beklet_sensor3 = 0;
int kes = HIGH;
unsigned long time;
unsigned long zaman = 0;
int analogInput = 0;
float vout = 0.0;
float vin = 0.0;
float R1 = 100000.0; // 100K ohm direnç
float R2 = 10000.0; // 10K ohm direnç
int value = 0;
void setup()
{
pinMode(sensor1, INPUT);
pinMode(sensor2, INPUT);
pinMode(sensor3, INPUT);
pinMode(alarm, OUTPUT);
pinMode(beklet_sensor2, INPUT);
pinMode(beklet_sensor3, INPUT);
Serial.begin(9600);
attachInterrupt(0,kesme,RISING);
pinMode(analogInput, INPUT);
}
void loop()
{
value = analogRead(analogInput);
vout = (value * 5.0) / 1024.0;
vin = vout / (R2/(R1+R2));
if (vin<0.09) {
vin=0.0;
}
Serial.println(vin);
if (vin <= 10){
digitalWrite(akuled,HIGH);
}
durum_sensor1 = digitalRead(sensor1);
durum_sensor2 = digitalRead(sensor2);
durum_sensor3 = digitalRead(sensor3);
durum_beklet_sensor2 = digitalRead(beklet_sensor2);
durum_beklet_sensor3 = digitalRead(beklet_sensor3);
if (durum_beklet_sensor2 == 1){
durum_sensor2 = 1;
Serial.println("kisa gecikme devrede");
zaman = millis();
while(millis() < zaman+10000);
durum_sensor2 = digitalRead(sensor2);
}
if (durum_beklet_sensor3 == 1){
durum_sensor3 = 1;
Serial.println("uzun gecikme devrede");
zaman = millis();
while(millis() < zaman+15000);
durum_sensor3 = digitalRead(sensor3);
}
if (durum_sensor1 == 0){
digitalWrite(alarm,HIGH);
Serial.println("ani_buton_devrede");
time = millis();
while(millis() < time+10000);
digitalWrite(alarm,LOW);
}
if(durum_sensor2 == 0){
Serial.println("kısa_süre_devrede");
digitalWrite(alarm,HIGH);
time = millis();
while(millis() < time+10000);
digitalWrite(alarm,LOW);
}
if(durum_sensor3 == 0){
Serial.println("uzun_süre_devrede");
digitalWrite(alarm,HIGH);
time = millis();
while(millis() < time+10000);
digitalWrite(alarm,LOW);
}
else {
digitalWrite(alarm,LOW);
}
}
void kesme()
{
digitalWrite(alarm,kes);
digitalWrite(alarm,LOW);
Serial.println("Alarm kapatıldı");
}