| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- #include "My_Eeprom.h"
- #include <EEPROM.h>
- #include "Testeur.h"
- void setup() {
- Serial.begin(115200);
-
- pinMode(pinBRAS1, INPUT);
- pinMode(pinBRAS2, INPUT);
- pinMode(pinOSMOL, INPUT);
- pinMode(pinCHAUF, INPUT);
- pinMode(pinECUME, INPUT);
- pinMode(pinREMON, INPUT);
-
- pinMode(pinTECBA,OUTPUT);
- pinMode(pinTECHA,INPUT);
- pinMode(pinCUVAU,INPUT);
- pinMode(pinRESBA,INPUT);
- attachInterrupt(digitalPinToInterrupt(pinBRAS1), fc_BRAS1, CHANGE); //CHANGE, RISING,FALLING
- attachInterrupt(digitalPinToInterrupt(pinBRAS2), fc_BRAS2, CHANGE); //CHANGE, RISING,FALLING
- attachInterrupt(digitalPinToInterrupt(pinOSMOL), fc_OSMO, CHANGE); //CHANGE, RISING,FALLING
- attachInterrupt(digitalPinToInterrupt(pinCHAUF), fc_CHAUFF, CHANGE); //CHANGE, RISING,FALLING
- attachInterrupt(digitalPinToInterrupt(pinECUME), fc_ECUM, CHANGE); //CHANGE, RISING,FALLING
- attachInterrupt(digitalPinToInterrupt(pinREMON), fc_REMO, CHANGE); //CHANGE, RISING,FALLING
- randomSeed(analogRead(0));
-
- }
- void loop() {
- NiveauBas();
- if(digitalWrite(pinTECHA)){
- Enregistre(TEHON);
- }
- if(digitalWrite(pinCUVAU)){
- Enregistre(CUHON);
- }
- if(digitalWrite(pinRESBA)){
- Enregistre(REBON);
- }
- delay(DELAYLOOP);
- }
- void NiveauBas(void){
- if (random(60*60*1000))/DELAYLOOP)==1){
- digitalWrite(pinTECBA,HIGH);
- Enregistre(TEBON);
- //Rajouter un test pour la non remonter du niveau d'eau
- delay(random(1000,2000));
- digitalWrite(pinTECBA,LOW);
- Enregistre(TEBOF);
- }
- }
- void fc_BRAS1() {
- if(digitalRead(pinBRAS1)){
- Enregistre(BR1ON);
- }
- else{
- Enregistre(BR1OF);
- }
- }
- void fc_BRAS2() {
- if(digitalRead(pinBRAS2)){
- Enregistre(BR2ON);
- }
- else{
- Enregistre(BR2OF);
- }
- }
- void fc_OSMO() {
- if(digitalRead(pinOSMOL)){
- Enregistre(OSMON);
- }
- else{
- Enregistre(OSMOF);
- }
- }
- void fc_CHAUFF() {
- if(digitalRead(pinCHAUF)){
- Enregistre(CHAON);
- }
- else{
- Enregistre(CHAOF);
- }
- }
- void fc_ECUM() {
- if(digitalRead(pinECUME)){
- Enregistre(ECUON);
- }
- else{
- Enregistre(ECUOF);
- }
- }
- void fc_REMO() {
- if(digitalRead(pinREMON)){
- Enregistre(REMON);
- }
- else{
- Enregistre(REMOF);
- }
- }
|