bonjour,
j'ai d'abords écrit ça :
#include "Wire.h"
#include "RTClib.h"
RTC_DS1307 RTC;
int AnaBtnIn = 0;
byte Slot [48];
byte data1 [24];
byte data2 [24];
int LcdBouton()
{
AnaBtnIn = analogRead(0);
if (AnaBtnIn > 1000) return 0;
if (AnaBtnIn < 80) return 1;
if (AnaBtnIn < 280) return 2;
if (AnaBtnIn < 470) return 3;
if (AnaBtnIn < 670) return 4;
if (AnaBtnIn < 870) return 5;
return 0;
}
void setup() {
Serial.begin(9600);
Wire.begin();
RTC.begin();
}
void loop() {
if (LcdBouton() == 3){
for (int i = 0; i < 48; i++){
Slot [i] = 132;
Serial.println (Slot [i]);
}
delay (1000);
}
if (LcdBouton() == 4){
RTC.writeByteInRam (0x08, Slot [0]);
RTC.writeByteInRam (0x09, Slot [1]);
RTC.writeByteInRam (0x0a, Slot [2]);
RTC.writeByteInRam (0x0b, Slot [3]);
RTC.writeByteInRam (0x0c, Slot [4]);
RTC.writeByteInRam (0x0d, Slot [5]);
RTC.writeByteInRam (0x0e, Slot [6]);
RTC.writeByteInRam (0x0f, Slot [7]);
RTC.writeByteInRam (0x10, Slot [8]);
RTC.writeByteInRam (0x11, Slot [9]);
RTC.writeByteInRam (0x12, Slot [10]);
RTC.writeByteInRam (0x13, Slot [11]);
RTC.writeByteInRam (0x14, Slot [12]);
RTC.writeByteInRam (0x15, Slot [13]);
RTC.writeByteInRam (0x16, Slot [14]);
RTC.writeByteInRam (0x17, Slot [15]);
RTC.writeByteInRam (0x18, Slot [16]);
RTC.writeByteInRam (0x19, Slot [17]);
RTC.writeByteInRam (0x1a, Slot [18]);
RTC.writeByteInRam (0x1b, Slot [19]);
RTC.writeByteInRam (0x1c, Slot [20]);
RTC.writeByteInRam (0x1d, Slot [21]);
RTC.writeByteInRam (0x1e, Slot [22]);
RTC.writeByteInRam (0x1f, Slot [23]);
RTC.writeByteInRam (0x20, Slot [24]);
RTC.writeByteInRam (0x21, Slot [25]);
RTC.writeByteInRam (0x22, Slot [26]);
RTC.writeByteInRam (0x23, Slot [27]);
RTC.writeByteInRam (0x24, Slot [28]);
RTC.writeByteInRam (0x25, Slot [29]);
RTC.writeByteInRam (0x26, Slot [30]);
RTC.writeByteInRam (0x27, Slot [31]);
RTC.writeByteInRam (0x28, Slot [32]);
RTC.writeByteInRam (0x29, Slot [33]);
RTC.writeByteInRam (0x2a, Slot [34]);
RTC.writeByteInRam (0x2b, Slot [35]);
RTC.writeByteInRam (0x2c, Slot [36]);
RTC.writeByteInRam (0x2d, Slot [37]);
RTC.writeByteInRam (0x2e, Slot [38]);
RTC.writeByteInRam (0x2f, Slot [39]);
RTC.writeByteInRam (0x30, Slot [40]);
RTC.writeByteInRam (0x31, Slot [41]);
RTC.writeByteInRam (0x32, Slot [42]);
RTC.writeByteInRam (0x33, Slot [43]);
RTC.writeByteInRam (0x34, Slot [44]);
RTC.writeByteInRam (0x35, Slot [45]);
RTC.writeByteInRam (0x36, Slot [46]);
RTC.writeByteInRam (0x37, Slot [47]);
delay (1000);
}
if (LcdBouton() == 5){
RTC.readBytesInRam (0x08, 48, Slot);
delay (1000);
for (int i = 0 ; i<48;i++){
Serial.println (Slot [i]);
}
}
}
écriture slot après slot et lecture en une fois.
les 16 dernière valeurs sont lues à 255.
puis j'ai écrit ça :
#include "Wire.h"
#include "RTClib.h"
RTC_DS1307 RTC;
int AnaBtnIn = 0;
word Slot [48];
byte data1 [24];
byte data2 [24];
int LcdBouton()
{
AnaBtnIn = analogRead(0);
if (AnaBtnIn > 1000) return 0;
if (AnaBtnIn < 80) return 1;
if (AnaBtnIn < 280) return 2;
if (AnaBtnIn < 470) return 3;
if (AnaBtnIn < 670) return 4;
if (AnaBtnIn < 870) return 5;
return 0;
}
void setup() {
Serial.begin(9600);
Wire.begin();
RTC.begin();
}
void loop() {
if (LcdBouton() == 3){
for (int i = 0; i < 48; i++){
Slot [i] = 132;
Serial.println (Slot [i]);
}
delay (1000);
}
if (LcdBouton() == 4){
RTC.writeByteInRam (0x08, Slot [0]);
RTC.writeByteInRam (0x09, Slot [1]);
RTC.writeByteInRam (0x0a, Slot [2]);
RTC.writeByteInRam (0x0b, Slot [3]);
RTC.writeByteInRam (0x0c, Slot [4]);
RTC.writeByteInRam (0x0d, Slot [5]);
RTC.writeByteInRam (0x0e, Slot [6]);
RTC.writeByteInRam (0x0f, Slot [7]);
RTC.writeByteInRam (0x10, Slot [8]);
RTC.writeByteInRam (0x11, Slot [9]);
RTC.writeByteInRam (0x12, Slot [10]);
RTC.writeByteInRam (0x13, Slot [11]);
RTC.writeByteInRam (0x14, Slot [12]);
RTC.writeByteInRam (0x15, Slot [13]);
RTC.writeByteInRam (0x16, Slot [14]);
RTC.writeByteInRam (0x17, Slot [15]);
RTC.writeByteInRam (0x18, Slot [16]);
RTC.writeByteInRam (0x19, Slot [17]);
RTC.writeByteInRam (0x1a, Slot [18]);
RTC.writeByteInRam (0x1b, Slot [19]);
RTC.writeByteInRam (0x1c, Slot [20]);
RTC.writeByteInRam (0x1d, Slot [21]);
RTC.writeByteInRam (0x1e, Slot [22]);
RTC.writeByteInRam (0x1f, Slot [23]);
RTC.writeByteInRam (0x20, Slot [24]);
RTC.writeByteInRam (0x21, Slot [25]);
RTC.writeByteInRam (0x22, Slot [26]);
RTC.writeByteInRam (0x23, Slot [27]);
RTC.writeByteInRam (0x24, Slot [28]);
RTC.writeByteInRam (0x25, Slot [29]);
RTC.writeByteInRam (0x26, Slot [30]);
RTC.writeByteInRam (0x27, Slot [31]);
RTC.writeByteInRam (0x28, Slot [32]);
RTC.writeByteInRam (0x29, Slot [33]);
RTC.writeByteInRam (0x2a, Slot [34]);
RTC.writeByteInRam (0x2b, Slot [35]);
RTC.writeByteInRam (0x2c, Slot [36]);
RTC.writeByteInRam (0x2d, Slot [37]);
RTC.writeByteInRam (0x2e, Slot [38]);
RTC.writeByteInRam (0x2f, Slot [39]);
RTC.writeByteInRam (0x30, Slot [40]);
RTC.writeByteInRam (0x31, Slot [41]);
RTC.writeByteInRam (0x32, Slot [42]);
RTC.writeByteInRam (0x33, Slot [43]);
RTC.writeByteInRam (0x34, Slot [44]);
RTC.writeByteInRam (0x35, Slot [45]);
RTC.writeByteInRam (0x36, Slot [46]);
RTC.writeByteInRam (0x37, Slot [47]);
delay (1000);
}
if (LcdBouton() == 5){
RTC.readBytesInRam(0x08, 24, data1);
RTC.readBytesInRam(0x20,24,data2);
for (int i = 0 ; i<24;i++){
Slot [i] = data1 [i];
}
for (int i = 24 ; i < 48 ; i++){
Slot [i] = data2 [i-24];
}
delay (1000);
for (int i = 0 ; i<48;i++){
Serial.println (Slot [i]);
}
}
}
écriture slot par slot et lecture en deux fois et là, les valeurs sont toutes lues correctement.