j’ai rebossé mon code et j'arrive maintenant à prétendre afficher quelque chose sur mon afficheur mais celui ci m’affiche "8.8.8.8." .
Voici les améliorations que j'ai apporter à mon programmes grâce a vos conseils et a quelques recherches.
#include <Wire.h>
#include <MD_DS3231.h>
const int SER = 7; // DS: Serial data input (Data)
const int RCLK = 12; // SH_CP: Shift register clock pin (Clock)
const int SRCLK = 8; // ST_CP: Storage register clock pin (latch pin) (Latch)
const int D1 = 9;
const int D2 = 6;
const int D3 = 11;
const int D4 = 10;
const int pinphotoresistance = A3;
byte heures;
byte minutes;
byte uniheure;
byte dizheure;
byte unimins;
byte dizmins;
// Describe each digit in terms of display segments
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
const byte numbers[10] = {
0b00000011,
0b10011111,
0b00100101,
0b00001101,
0b10011001,
0b01001001,
0b01000001,
0b00011111,
0b00000001,
0b00001001,
/* 0b00010001,
0b11000001,
0b01100011,
0b10000101,
0b01100001,
0b01110001 lettres A à F */
};
void setup()
{
Serial.begin(9600);
Wire.begin(); //D�marrage de la librairie wire.h
RTC.readTime();
heures = RTC.h;
minutes = RTC.m;
pinMode(SER, OUTPUT);
pinMode(RCLK, OUTPUT);
pinMode(SRCLK, OUTPUT);
pinMode(D1, OUTPUT);
pinMode(D2, OUTPUT);
pinMode(D3, OUTPUT);
pinMode(D4, OUTPUT);
}
void loop()
{
byte valphotoresistance = analogRead(pinphotoresistance) / 4 + 1;
Serial.println(valphotoresistance);
dizmins = minutes / 10; //récupère les dizaines de minutes
unimins = minutes - dizmins * 10; //récupère les unités de minutes
dizheure = heures / 10; //récupère les dizaines des heures
uniheure = heures - dizheure * 10; //récupère les unités des heures
shiftIt(numbers[dizheure]);
analogWrite(D1, valphotoresistance);
delay(2);
analogWrite(D1, 0);
shiftIt(numbers[uniheure]);
analogWrite(D2, valphotoresistance);
delay(2);
analogWrite(D2, 0);
shiftIt(numbers[dizmins]);
analogWrite(D3, valphotoresistance);
delay(2);
analogWrite(D3, 0);
shiftIt(numbers[unimins]);
analogWrite(D4, valphotoresistance);
delay(2);
analogWrite(D4, 0);
}
void shiftIt (byte data)
{
// Set latchPin LOW while clocking these 8 bits in to the register
digitalWrite(RCLK, LOW);
for (int k = 0; k <= 7; k++) {
// clockPin LOW prior to sending a bit
digitalWrite(SRCLK, LOW);
if ( data & (1 << k) ) {
digitalWrite(SER, HIGH); // turn “On”
}
else {
digitalWrite(SER, LOW); // turn “Off”
}
// and clock the bit in
digitalWrite(SRCLK, HIGH);
}
//set latchPin to high to lock and send data
digitalWrite(RCLK, HIGH);
// put delay here if you want to see the multiplexing in action!
}
merci de votre aide.