From 1bf5553ad85ea297bc269066fedfba126798a3c3 Mon Sep 17 00:00:00 2001 From: Pierrick C Date: Sat, 7 Jan 2017 21:31:31 +0100 Subject: [PATCH] Add new file : cavapapa.ino --- code/cavapapa.ino | 93 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 code/cavapapa.ino diff --git a/code/cavapapa.ino b/code/cavapapa.ino new file mode 100644 index 0000000..33359c9 --- /dev/null +++ b/code/cavapapa.ino @@ -0,0 +1,93 @@ +#include +#ifdef __AVR__ + #include +#endif + +#define LED_PIN 0 +#define RELAY_PIN 1 +#define BAT_PIN 1 // Analog Input 1 = digital PIN 2 +#define VMAX 486 // = ~13.5V avec des résistances de 47k et 10k +#define V_GREEN 431 // = ~12V tension pour vert pur +#define VMIN 395 // = ~11 V +#define V_ALERTE 413 // = ~11.5V provoque clignotement 3 fois rapide +#define V_OFF 388 // = ~10.8V provoque clignotement pendant 15s puis OFF +#define OFF_DELAY 15 // delais de clignotement (en secondes) avant extinction à l'atteinte de V_OFF +#define INIT_BLINK 100 + +Adafruit_NeoPixel neopix = Adafruit_NeoPixel(1, LED_PIN, NEO_RGB + NEO_KHZ800); + +byte timer = 100; +byte low_bat_counter = 0; +int vbat = 0; +int red = 0; +int green = 0; +bool warned = 0; + +void blink(int n=3, int t=500) { + for(int i=0;i10) { + blink(OFF_DELAY, 500); + digitalWrite(RELAY_PIN, LOW); + while(1); + } + + delay(1000); +}