1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
| #include "DFRobot_PH.h"
#include <EEPROM.h>
#include <Wire.h>
#include<LiquidCrystal_I2C.h>
#define PH_PIN A1
#define pinBoutonEnter 2
#define pinBoutonCal 4
#define pinBoutonExit 7
LiquidCrystal_I2C lcd(0x27, 20, 4);
boolean lastBoutonEnter = LOW; //a
boolean lastBoutonCal = LOW;
boolean lastBoutonExit = LOW;
boolean etatBoutonEnter;
boolean etatBoutonCal;
boolean etatBoutonExit;
void setup()
{
Serial.begin(BAUD);
ph.begin();
lcd.init(); // initialisation de l'afficheur
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Appuyer ETALON ");
lcd.setCursor(0, 1);
lcd.print("pour etalonnage ");
lcd.setCursor(0, 2);
lcd.print("ou attendre 10s ");
lcd.setCursor(0, 3);
lcd.print("pour mesurer pH ");
}
void loop()
{
lcd.backlight();
boolean testBoutonEnter = 0; //variable pour savoir si on rentre dans la boucle de calibration
boolean testBoutonCal = 0; //variable pour savoir si on valide l'étalonnage
boolean testBoutonExit = 0; //variable pour quitter le mode étalonnage
static unsigned long timepoint = millis();
//on teste si le bouton ENTER est pressé --> si oui, on rentre dans le mode de calibration
etatBoutonEnter=digitalRead(pinBoutonEnter);
if (etatBoutonEnter != lastBoutonEnter)
{
delay(20);
etatBoutonEnter=digitalRead(pinBoutonEnter);
if (etatBoutonEnter == HIGH)
{
testBoutonEnter=1;
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("ENTER appuye");
lcd.setCursor(0,3);
lcd.print(testBoutonEnter);
while (testBoutonEnter==1)
{
//on teste si le bouton CAL est pressé --> si oui, on valide l'étalonnage
etatBoutonCal=digitalRead(pinBoutonCal);
if (etatBoutonCal != lastBoutonCal)
{
delay(20);
etatBoutonCal=digitalRead(pinBoutonCal);
if (etatBoutonCal == HIGH)
{
testBoutonCal = 1;
lcd.backlight();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Appui CAL ap enter");
lcd.setCursor(0,3);
lcd.print(testBoutonEnter);
testBoutonEnter=0;
}
}
}
}
}
//on teste si le bouton CAL est pressé --> si oui, on valide l'étalonnage
etatBoutonCal=digitalRead(pinBoutonCal);
if (etatBoutonCal != lastBoutonCal)
{
delay(20);
etatBoutonCal=digitalRead(pinBoutonCal);
if (etatBoutonCal == HIGH)
{
testBoutonCal = 1;
lcd.backlight();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Appui CAL seul");
lcd.setCursor(0,3);
lcd.print(testBoutonEnter);
}
}
lastBoutonEnter=etatBoutonEnter;
lastBoutonCal=etatBoutonCal;
} |
Partager