Code :
const int PHOTOCELL_PIN = A0 ;
const int BUZZER_PIN = 3 ;
lectures de tension sont à 0-1023 gamme
const int seuil = 500 ;
void setup() {}
pinMode (entrée, PHOTOCELL_PIN) ;
Serial.Begin(9600) ;
}
long alarmEndTime = 0 ;
void loop() {}
int niveau = analogRead(PHOTOCELL_PIN) ;
Serial.println(Level) ;
longtemps = millis() ;
Si (temps < alarmEndTime) {}
timeLeft long = alarmEndTime - temps ;
Si {(timeLeft % 1000 > 300)
ton (BUZZER_PIN, 4000) ;
} else {}
noTone(BUZZER_PIN) ;
}
} else {}
noTone(BUZZER_PIN) ;
Si (niveau < seuil) {}
alarmEndTime = temps + 3000 ;
}
}
}