Bonjour,
Tout d’abort je vous souhaite une bonne année 2024 avec plein de nouveaux projets.
j’aimerai réaliser une Wordclock en français, j’ai trouvé un tutoriel sur internet et j’ai un problème avec le programme Arduino (je suis novice en programmation).
Sur le programme il faut la bibliothèque WProgram.h que je ne trouve pas et j’ai lu qu’il faut la remplacer par Arduino.h, mais quand je lance la vérification du programme j’ai l’erreur ‘’RTC was not declared in this scope’’.
J’utilise un carte Arduino nano.
Je vous remercie par avance de votre aide
ci-dessous le programme

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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
#include <Arduino.h>  // les 3 librairies pour le rtc
#include <Wire.h>
#include <RTClib.h>
 
int rtc[7];
int Bouton1=3;
int Bouton2=4;
int Detecteur=7;
 
 
void Set_Square_Wave(int rate){  // set the square wave output on pin 7 of the DS1307 chip
  rate = rate + 144;                         // add 0x90 (dec 144) to rate
  Wire.beginTransmission(0x68);              // write the control register
  Wire.write(0x07);                           // register address 07H)
  Wire.write(rate);                           // 90H=1Hz, 91H=4kHz, 92H=8kHz, 93H=32kHz
  Wire.endTransmission();
}
 
 int latchPin=8;     // 3 lignes pour le shift out
 int clockPin=12;
 int dataPin=11;
 
 
 int Compteur1=0;
 int Compteur2=0;
 int Compteur3=0;
 int Coef=0;
 int alea=0;
 int k=1;
 int Var1=0;
 int Var2=0;
 int Ancvar1=0;
 int Ancvar2=0;
 int Temp1=1000; // tempo pour mise en veille
 int Temp2=400;  // tempo pour rafraichir
 int Inc=0;
 int Allumer=0;
 int Presence=1;
 
 
void setup()
{
 
  pinMode(Bouton1,INPUT);// déclaration des entrées
  pinMode(Bouton2,INPUT);
  pinMode(Detecteur,INPUT);
 
  digitalWrite(Bouton1, HIGH);  // entrées par défaut à 1, évite une résistance de pull-UP.
  digitalWrite(Bouton2, HIGH);
 
 // Décommenter la partie suivante et mettez vos valeurs pour initialiser l'horloge
 
  //RTC.stop();
  //RTC.set(DS1307_SEC,0);    // Secondes
  //RTC.set(DS1307_MIN,10);   // Minutes
  //RTC.set(DS1307_HR,4);    // Heures
  //RTC.set(DS1307_DOW,3);    // Jour de la semaine
  //RTC.set(DS1307_DATE,7);  // Jour du mois
  //RTC.set(DS1307_MTH,11);   // Mois
  //RTC.set(DS1307_YR,12);    // Année
  //RTC.start();
 
 
 
  // Mettre une resistance de pull up entre pin 7 et Vbat
  // 0=1hz, 1=4KHz, 2=8KHz, 3=32KHz
  Set_Square_Wave(0); // 1Hz
 
 
 pinMode(latchPin,OUTPUT);
 pinMode(clockPin,OUTPUT);
 pinMode(dataPin,OUTPUT);
 
 
}
 
void loop()
{
 delay(50);
  RTC.get(rtc,true);
 
  Presence=digitalRead(Detecteur);
  if (Presence==1) Temp1=2000;
 
 
 
  Var1=1-digitalRead(Bouton1);
  Var2=1-digitalRead(Bouton2);
 
  if (Var1==0) Ancvar1=0;
  if (Var2==0) Ancvar2=0;
 
   if (Var1!=Ancvar1) // Front Montant du bouton 1
   {
     Inc=rtc[1]+5;
     if (Inc>59) Inc=0;
 
 
     RTC.stop();    
     RTC.set(DS1307_MIN,Inc);
     RTC.start();
 
     Temp1=1000;
     affichage();
     Ancvar1=1;
 
 
 
   }
 
  if (Var2!=Ancvar2) // Front Montant du bouton 2
   {
 
     Inc=rtc[2]+1;
      if (Inc>23) Inc=0;
 
     RTC.stop();
     RTC.set(DS1307_HR,Inc);
     RTC.start();
 
     Temp1=1000;
     affichage();
      Ancvar2=1;
   }
 
 
    Temp1-- ;
    if (Temp1<0) Temp1=0;
 
    if (Temp1>0) {
      if (Allumer==0) {   // lancer l'animation à l'allumage
        alea=random(100);
         if (alea>50){
           deco1();}
         else {
           deco2();}
      }
      Allumer=1;
      Temp2++;
      if (Temp2>400) {
         Temp2=0;
         affichage();
 
      }
    }
    else {
     if (Allumer==1){
       eteindre();
       Allumer=0;
     }
    }
 
 
 
}
 
void shiftOut(byte dataOut) {
 
 boolean pinState;
 digitalWrite (dataPin, LOW);
 digitalWrite (clockPin, LOW);
 
 for (int i=0; i<=7; i++) {
  digitalWrite(clockPin, LOW);
  if (dataOut & (1<<i)) {
   pinState=HIGH;
  }
  else {
   pinState=LOW;
  }
 
 digitalWrite(dataPin,pinState);
 digitalWrite (clockPin, HIGH);
 digitalWrite (dataPin, LOW);
 }
 
 digitalWrite (clockPin, LOW);
 
}
 
void  deco1() {
 
  for (int i=1; i <= 10; i++){
     k=1;
       for (int j=0; j <= 7; j++){
 
 
          digitalWrite(latchPin, LOW);
          alea=random(0,2);
          shiftOut(k*alea);
          alea=random(0,2);
          shiftOut(k*alea);
          alea=random(0,2);
          shiftOut(k*alea);
          digitalWrite(latchPin, HIGH);
          delay(20);
          k=k*2;
 
        }
     }
 
 
}
 
 
void deco2() {
 
    for (int i=0; i <= 25; i++){
 
     digitalWrite(latchPin, LOW);
    alea=random(250)+1;
    shiftOut(alea);
    alea=random(250)+1;
    shiftOut(alea);
    alea=random(250)+1;
    shiftOut(alea);
 
    digitalWrite(latchPin, HIGH);
    alea=random(200)+50;
    delay(alea);
 
    }
 
}
 
void affichage() {
 
    RTC.get(rtc,true);
 
 
     Temp2=400;
 
 
 
   // calcul de l'heure
 
   Compteur1=32;  // "Il est"
   Compteur2=0;
   Compteur3=160;  // "Heure" et "s"
 
   Coef=0;
   if (rtc[1]>34) {
     Coef=1;  // coef pour les heures
     Compteur3=Compteur3+2; // "Moins"
   }
 
 
     if (rtc[2]==1-Coef || rtc[2]==13-Coef) {
       Compteur2=Compteur2+8; // "Une"
       Compteur3=Compteur3-128; // Suppression du "S"
     }
 
     if (rtc[2]==2-Coef || rtc[2]==14-Coef) Compteur1=Compteur1+4; // "Deux"
     if (rtc[2]==3-Coef || rtc[2]==15-Coef) Compteur2=Compteur2+1; // "Trois"
     if (rtc[2]==4-Coef || rtc[2]==16-Coef) Compteur1=Compteur1+16; // "Quatre"
     if (rtc[2]==5-Coef || rtc[2]==17-Coef) Compteur2=Compteur2+32; // "Cinq"
     if (rtc[2]==6-Coef || rtc[2]==18-Coef) Compteur2=Compteur2+16; // "Six"
     if (rtc[2]==7-Coef || rtc[2]==19-Coef) Compteur1=Compteur1+8; // "Sept"
     if (rtc[2]==8-Coef || rtc[2]==20-Coef) Compteur2=Compteur2+2; // "Huit"
     if (rtc[2]==9-Coef || rtc[2]==21-Coef) Compteur1=Compteur1+64; // "Neuf"
     if (rtc[2]==10-Coef || rtc[2]==22-Coef) Compteur3=Compteur3+4; // "Dix"
     if (rtc[2]==11-Coef || rtc[2]==23-Coef) Compteur1=Compteur1+128; // "Onze"
     if (rtc[2]==12-Coef) {
       Compteur1=Compteur1+1; // "Midi"
       Compteur3=Compteur3-160; // Suppression de "heure" et de "S"
     }
     if ((rtc[2]==0 && Coef==0)||(rtc[2]==23 && Coef==1)) Compteur3=Compteur3-152; // "Minuit" et Suppression de "heure" et de "s" (8-160)=-152
 
    if ((rtc[1]>4 && rtc[1]<10)||(rtc[1]>54)||(rtc[1]>24 && rtc[1]<30)||(rtc[1]>34 && rtc[1]<40)) Compteur3=Compteur3+16;  // "Cinq" (minutes)
    if ((rtc[1]>9 && rtc[1]<15)||(rtc[1]>49 && rtc[1]<55)) Compteur2=Compteur2+4; // "Dix" (minutes)
    if ((rtc[1]>19 && rtc[1]<30)||(rtc[1]>34 && rtc[1]<45)) Compteur3=Compteur3+1;  // "Vingt"
    if ((rtc[1]>14 && rtc[1]<20)||(rtc[1]>44 && rtc[1]<50)) Compteur2=Compteur2+64;  // "Quart"
    if ((rtc[1]>14 && rtc[1]<20)||(rtc[1]>29 && rtc[1]<35))  Compteur1=Compteur1+2; // "Et"
    if (rtc[1]>44 && rtc[1]<50)  Compteur3=Compteur3+64; // "Le"
    if (rtc[1]>29 && rtc[1]<35) Compteur2=Compteur2+128; // "Demi"
 
 
   // affichage de l'heure
    digitalWrite(latchPin, LOW);
    shiftOut(Compteur3);
    shiftOut(Compteur2);
    shiftOut(Compteur1);
    digitalWrite(latchPin, HIGH);
 
}
 
 
void eteindre(){
   digitalWrite(latchPin, LOW);
    shiftOut(0);
    shiftOut(0);
    shiftOut(0);
    digitalWrite(latchPin, HIGH);
}