/* Cave_a_Papa Copyright (C) 2017 Pierrick C. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation version 3 of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see */ #ifdef __AVR__ #include #endif #define LED_R_PIN 11 #define LED_V_PIN 10 #define LED_B_PIN 9 #define RELAY_PIN 2 #define BAT_PIN A1 // Analog Input 0 = digital PIN 2 #define VMAX 1250 #define V_GREEN 1170 // tension pour vert pur #define VMIN 950 #define V_ALERTE 970 // provoque clignotement 3 fois rapide #define V_OFF 920 // provoque clignotement pendant 15s puis OFF #define OFF_DELAY 10 // delais de clignotement (en secondes) avant extinction à l'atteinte de V_OFF #define INIT_BLINK 100 byte timer = 100; byte low_bat_counter = 0; int abat = 0; int analog = 0; int red = 0; int green = 0; float vbat = 0; bool warned = 0; void blink(int n=3, int t=500) { for(int i=0;i10) { Serial.println("Extinction : batterie trop faible"); blink(OFF_DELAY, 500); digitalWrite(RELAY_PIN, LOW); while(1) { for(int i=0;i<50;i++) { analogWrite(LED_R_PIN, i); delay(15); } for(int i=50;i>0;i--) { analogWrite(LED_R_PIN, i); delay(15); } } } delay(2000); }