Bonsoir,
je souhaite réaliser un coupe gâteau automatique. Pour cela, je sélectionne le nombre de parts souhaitées sur un écran LCD de référence Adafruit_RGBLCDShield. Cet écran possède des boutons poussoirs permettant d'augmenter le nombre de parts ainsi que de confirmer ce nombre. Or, lorsque je téléverse mon programme, l'écran s'allume, on voit "Nombre Parts : 2", mais impossible d'augmenter ce nombre, et je ne vois pas le problème. De plus, le programme contrôle également un moteur, mettant en rotation la plateau. Je vous laisse y jeter un œil afin de repérer une quelconque faute :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
 
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield(); 
 
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7
#define maSortie       
 
int DirB = 8;
int BrakeB = 13;
int nbrPart = 1;
int I=0;
 
 
void setup() {
 
 
 
  lcd.begin(16, 2);         
  int time = millis();   
  lcd.print("Nbre parts : ");       
 
 
  pinMode(DirB,OUTPUT);
  pinMode(BrakeB,OUTPUT);
  }
 
void loop() {
    lcd.setCursor(0, 1);
 
 
  uint8_t buttons = lcd.readButtons();
 
  if (buttons) {
    lcd.clear();
    lcd.setCursor(0,0);
 
    if (buttons & BUTTON_LEFT) {
      nbrPart= nbrPart +1;
      if (nbrPart > 10) {
      nbrPart= 2; 
      }
 
      delay(200);
 
 
     lcd.print("Nbre parts = ");
     lcd.print(nbrPart);
 
 
    }
    if (buttons & BUTTON_SELECT) {
       lcd.print("Nbre parts validé");
    }
   }
  if (nbrPart==2) {
   while(I < nbrPart){ 
    digitalWrite(DirB, HIGH);
    digitalWrite(BrakeB, LOW);
    delay(2431);
    digitalWrite(DirB, LOW);
    digitalWrite(BrakeB, LOW);
    I=I+1;
  }
  }
 if (nbrPart==3) {
    while(I < nbrPart){
    digitalWrite(DirB, HIGH);
    digitalWrite(BrakeB, LOW);
    delay(2161);
    digitalWrite(DirB, LOW);
    digitalWrite(BrakeB, LOW);
    I=I+1;
  }
 }
 if (nbrPart==4) {
    while(I < nbrPart){
    digitalWrite(DirB, HIGH);
    digitalWrite(BrakeB, LOW);
    delay(2026);
    digitalWrite(DirB, LOW);
    digitalWrite(BrakeB, LOW);
    I=I+1;
  }
 }
 if (nbrPart==5) {
    while(I < nbrPart){
    digitalWrite(DirB, HIGH);
    digitalWrite(BrakeB, LOW);
    delay(1945);
    digitalWrite(DirB, LOW);
    digitalWrite(BrakeB LOW);
    I=I+1;
  }
 }
 if (nbrPart==6){
    while(I < nbrPart){
    digitalWrite(DirB, HIGH);
    digitalWrite(BrakeB, LOW);
    delay(1891);
    digitalWrite(DirB, LOW);
    digitalWrite(BrakeB, LOW);
    I=I+1;
    }
 }
 if (nbrPart==7) {
    while(I < nbrPart){
    digitalWrite(DirB, HIGH);
    digitalWrite(BrakeB, LOW);
    delay(1853);
    digitalWrite(DirB, LOW);
    digitalWrite(BrakeB, LOW);
    I=I+1;
  }
 }
 if (nbrPart==8) {
    while(I < nbrPart){
    digitalWrite(DirB, HIGH);
    digitalWrite(BrakeB, LOW);
    delay(1823);
    digitalWrite(DirB, LOW);
    digitalWrite(BrakeB, LOW);
    I=I+1;
  }
 }
 if (nbrPart==9) {
    while(I < nbrPart){
    digitalWrite(DirB, HIGH);
    digitalWrite(BrakeB, LOW);
    delay(1801);
    digitalWrite(DirB, LOW);
    digitalWrite(BrakeB, LOW);
    I=I+1;
  }
 }
 if (nbrPart==10) {
    while(I < nbrPart){
    digitalWrite(DirB, HIGH);
    digitalWrite(BrakeB, LOW);
    delay(1783);
    digitalWrite(DirB, LOW);
    digitalWrite(BrakeB, LOW);
    I=I+1;
  }
}
 I=0;
 }