Bonjour! J’ai réalisé un algorithme Arduino faisant intervenir un décompte. Or, ce même décompte ne fonctionne pas… Tout le reste fonctionne, mais pas celui-ci.. Je vous laisse lire ce dit algorithme : #include <Wire.h> #include "rgb_lcd.h"
int decompte=0;
int sec=0;
rgb_lcd lcd;
int secu=0;
int T=0;
int temperature[4]={0,1,2,3};
int volume[3]={0,1,2};
int V=0;
int temps[4][3]=
{
{80, 90, 100},
{110, 120, 130},
{140, 150, 160},
{170, 180, 190},
};
const int colorR = 0;
const int colorG = 0;
const int colorB = 255;
const int BOUTON_1 = 8;
const int BOUTON_2 = 7;
const int BOUTON_3 = 6;
const int BOUTON_4 = 5;
const int LED = 4;
int etat1;
int etat2;
int etat3;
int etat4;
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);
lcd.setRGB(colorR, colorG, colorB);
pinMode(LED, OUTPUT);
pinMode(BOUTON_1, INPUT);
pinMode(BOUTON_2, INPUT);
pinMode(BOUTON_3, INPUT);
pinMode(BOUTON_4, INPUT);
lcd.clear();
Serial.begin(9600);
}
void bouton() {
etat1 = digitalRead(BOUTON_1);
etat2 = digitalRead(BOUTON_2);
etat3 = digitalRead(BOUTON_3);
etat4 = digitalRead(BOUTON_4);
if (secu==0)
{
if (etat1 == HIGH)
{
T=0; delay(2000); lcd.clear(); etat1=LOW; secu=1;
}
if (etat2 == HIGH)
{
T=1; delay(2000); lcd.clear(); etat2=LOW; secu=1;
}
if (etat3 == HIGH)
{
T=2; delay(2000); lcd.clear();etat3=LOW; secu=1;
}
if (etat4 == HIGH)
{
T=3; delay(2000); lcd.clear();etat4=LOW; secu=1;
}
}
if(secu==1)
{
if(etat1 == HIGH)
{
V=0; secu=2; delay(2000);lcd.clear(); sec=temps[T][V]; etat1=LOW;
}
if(etat2 == HIGH)
{
V=1; secu=2; delay(2000);lcd.clear();sec=temps[T][V];etat2=LOW;
}
if(etat3 == HIGH)
{
V=2; secu=2; delay(2000);lcd.clear();sec=temps[T][V];etat3=LOW;
}
if(etat4 == HIGH)
{
secu=0; delay(2000);lcd.clear();etat4=LOW;
}
}
}
void menu1() {
lcd.setCursor(0, 0);
lcd.print("TEMPERATURE?");
lcd.setCursor(1, 1);
lcd.print("60");
lcd.setCursor(5, 1);
lcd.print("70");
lcd.setCursor(9, 1);
lcd.print("80");
lcd.setCursor(13, 1);
lcd.print("95");
}
void menu2() {
lcd.setCursor(0, 0);
lcd.print("VOLUME?");
lcd.setCursor(0, 1);
lcd.print("0,5");
lcd.setCursor(4,1);
lcd.print("0,8");
lcd.setCursor(9, 1);
lcd.print("1");
lcd.setCursor(12, 1);
lcd.print("BACK");
}
void menu3() {
if (sec=!0){
decompte=millis()%1000;
if(decompte==0)
{sec--;};
lcd.setCursor(7, 0);
lcd.print(sec);
}
else
{
digitalWrite(LED, HIGH);
delay(5000);
digitalWrite(LED, LOW);
lcd.clear();
secu=0;
}
}
void loop() {
if (secu==0) {
menu1();
bouton();
}
if (secu==1) {
menu2();
bouton();
}
if (secu==2) {
menu3();
}
+0
-0