Bien vu, j'avais négligé l'utilisation d'une librairie qui impose l'arrangement des sorties.
Et pour notre culture, je serais curieux de savoir comment on fabrique soi même un afficheur 13 segments de cette sorte.
A suivre.
Bien vu, j'avais négligé l'utilisation d'une librairie qui impose l'arrangement des sorties.
Et pour notre culture, je serais curieux de savoir comment on fabrique soi même un afficheur 13 segments de cette sorte.
A suivre.
byte num[] = {
B01111110, // Zero
B00110000, // One
B01101101, // Two
etc ...
Bonjour,
une petite remarque sans importance :
sauf à vouloir se conformer à une bibliothèque qui serait ainsi (mal ?) faite, il n'est pas nécessaire, voire peu élégant, de sortir l'abaque de la flash pour la mettre en ram
c'est un projet que j'aime bien ... moi fan de fabrication d'horloge 'home made' ... j'y a joute un affichage personnalisé et même copyright ... c'est le TOP !
bon je revois tous ca ... j'essaye d'avancer ... et le sujet reste ouvert ...
mon horloge qui affiche aussi la température et l'humidité ... donc j'ai besoin d'afficher aussi un °C et un %
et tu sauras faire avec seulement 4 digits ?
trimarco232:
et tu sauras faire avec seulement 4 digits ?
oui ... simple ... non ...
par exemple avec des afficheurs classique :
la température :
l'humidité :
Bonjour tous le monde
j'essai d'avancer un peu sur ce projet (vu que j'ai un peu de temps libre) ... j'essai de re-lire tous vos commentaires et d'effectuer des améliorations ... entre temps je vous poste le code de base de mon horloge (code allégé), j'ai supprimer la partie de température et d'humidité, et aussi la partie de réglage de l'heure, ce code juste lit le temps du module DS1703 (qui passera à un DS3231 afin d'améliorer la précision) et l'affiche ...
#include <TimeLib.h> //Time Library
#include <DS1307RTC.h> //Real Time Clock Library
#include <Wire.h> //Auxiliary Library for DS1307RTC (Real-Time Clock) - Pins to Arduino UNO: A4 (SDA), A5 (SCL)
int clockPin = 8; // Pin 8 of Arduino connected in the pin 11 of 74HC595 (Clock)
int latchPin = 9; // Pin 9 of Arduino connected in the pin 12 of 74HC595 (Latch)
int dataPin = 10; // Pin 10 of Arduino connected in the pin 14 of 74HC595 (Data)
//---------------------------------------------------
int hora, minuto, temp, umid;
int unidadeHora, unidadeMinuto, dezenaHora, dezenaMinuto;
int unidadeTemp, dezenaTemp, unidadeUmid, dezenaUmid;
//---------------------------------------------------
time_t t = now();
//Digits Matrix - 0 a 9
byte num[] = {
B01111110, // Zero
B00110000, // One
B01101101, // Two
B01111001, // Three
B00110011, // Four
B01011011, // Five
B01011111, // Six
B01110000, // Seven
B01111111, // Eight
B01111011, // Nine
};
void setup() {
pinMode(latchPin, OUTPUT); // Define the 3 digital pins as output
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
setSyncProvider(RTC.get); // Update the time with data of RTC (Real Time Clock)
}
//---------------
void loop() {
hora = hour();
minuto = minute();
unidadeHora = hora % 10;
dezenaHora = hora / 10;
unidadeMinuto = minuto % 10;
dezenaMinuto = minuto / 10;
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 8); //Set DISPLAY 1 (top view from left to right)
shiftOut(dataPin, clockPin, LSBFIRST, num[dezenaHora]); //Set the Hour (ten)
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no digit
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no segment
digitalWrite(latchPin, HIGH);
delayMicroseconds(500);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 4); //Set DISPLAY 2
shiftOut(dataPin, clockPin, LSBFIRST, num[unidadeHora]); //Set the Hour (unit)
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no digit
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no segment
digitalWrite(latchPin, HIGH);
delayMicroseconds(500);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 2); //Set DISPLAY 3
shiftOut(dataPin, clockPin, LSBFIRST, num[dezenaMinuto]); //Set the Minute (ten)
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no digit
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no segment
digitalWrite(latchPin, HIGH);
delayMicroseconds(500);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 1); //Set DISPLAY 4
shiftOut(dataPin, clockPin, LSBFIRST, num[unidadeMinuto]); //Set the Minute (unit)
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no digit
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no segment
digitalWrite(latchPin, HIGH);
delayMicroseconds(500);
}
donc sur cette base d'afficheur :
j'ai effectuer des changements dans le câblage
qui implique :
niveau code ... si je change (comme dit plus haut) la déclaration des caractères (unsigned int au lieu de byte) ... ca implique :
//Digits Matrix - 0 a 9
unsigned int num[] = {
B11111111,B00000000 // Zero
...
};
ou
//Digits Matrix - 0 a 9
unsigned int num[] = {
1111111100000000 // Zero
...
};
... eeeh ![]()
trimarco232:
Bonjour,
une petite remarque sans importance :
sauf à vouloir se conformer à une bibliothèque qui serait ainsi (mal ?) faite, il n'est pas nécessaire, voire peu élégant, de sortir l'abaque de la flash pour la mettre en ram
merci ... mais j'ai pas compris votre remarque ...
006.pdf (42.2 KB)
La réponse à ta question se trouve là Integer Constants - Arduino Reference
Autrement, il faut faire attention,lorsque tu as 2 registres à décalage cascadés tel que dans ton schéma le premier octet envoyé se retrouvera au final dans le second registre (on entre par le poids faible du premier registre et on décale vers la gauche).
fdufnews:
La réponse à ta question se trouve là Integer Constants - Arduino Reference
...
Merci
fdufnews:
... Autrement, il faut faire attention,lorsque tu as 2 registres à décalage cascadés tel que dans ton schéma le premier octet envoyé se retrouvera au final dans le second registre (on entre par le poids faible du premier registre et on décale vers la gauche).
ola ! .. c'est compliqué ce truc !!
on peut en tenir compte dans le soft,
ou bien dans le hard en chainant les registres dans l'ordre 2 -> 1 -> 3
trimarco232:
on peut en tenir compte dans le soft,
...
comme ca :
//Digits Matrix - 0 a 9
unsigned int num[] = {
B00000000,B11111111 // Zero
...
};
??
trimarco232:
on peut en tenir compte dans le soft,
ou bien dans le hard en chainant les registres dans l'ordre 2 -> 1 -> 3
donc inversion au niveau des connexions ? ce qui implique que les sorties Qa --> Qe du 1er HC595 seront connectés aux i-->m du digit ... et les sorties Qa --> Qh du 2eme HC595 seront connectés aux a-->h du digit ?
enfin ...
je prépare une maquette avec des petites leds (ce qui me permet d'éliminer la partie PMOS) afin d'effectuer mes 1er essais ...
esloch:
donc inversion au niveau des connexions ? ce qui implique que les sorties Qa --> Qe du 1er HC595 seront connectés aux i-->m du digit ... et les sorties Qa --> Qh du 2eme HC595 seront connectés aux a-->h du digit ?
WHAT !!!!!!!
Fais donc tes essais parce que là je crois voir un sac de noeuds dans l'ordre des bits.
mon prototype d'afficheur est ready ... c'est un seul digit ... pense pas que je fais en faire 4 ... inutile
il est beau non ?
mon code est prêt pour un 1er essai ... je l'ai modifier (normalement il compte de 0 jusqu’à 9) ... si vous avez des recommandations elles sont le bienvenu
#include <TimeLib.h> //Time Library
#include <DS1307RTC.h> //Real Time Clock Library
#include <Wire.h> //Auxiliary Library for DS1307RTC (Real-Time Clock) - Pins to Arduino UNO: A4 (SDA), A5 (SCL)
int clockPin = 8; // Pin 8 of Arduino connected in the pin 11 of 74HC595 (Clock)
int latchPin = 9; // Pin 9 of Arduino connected in the pin 12 of 74HC595 (Latch)
int dataPin = 10; // Pin 10 of Arduino connected in the pin 14 of 74HC595 (Data)
//---------------------------------------------------
//int hora, minuto, temp, umid;
int unidadeHora, unidadeMinuto, dezenaHora, dezenaMinuto;
int unidadeTemp, dezenaTemp, unidadeUmid, dezenaUmid;
//---------------------------------------------------
//time_t t = now();
int hora = 0;
int minuto = 0;
//Digits Matrix - 0 a 9 ... part 1
byte num1[] = {
B00000000, // Zero
B11010000, // One
B10101000, // Two
B00100000, // Three
B00101000, // Four
B00101000, // Five
B00101000, // Six
B00000000, // Seven
B00101000, // Eight
B00101000, // Nine
};
//Digits Matrix - 0 a 9 ... part 2
byte num2[] = {
B11111111, // Zero
B00001100, // One
B01101110, // Two
B11111100, // Three
B00110001, // Four
B11011101, // Five
B10011111, // Six
B11110000, // Seven
B11111111, // Eight
B11111001, // Nine
};
void setup() {
pinMode(latchPin, OUTPUT); // Define the 3 digital pins as output
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
//setSyncProvider(RTC.get); // Update the time with data of RTC (Real Time Clock)
}
//---------------
void loop() {
// hora = hour();
// minuto = minute();
unidadeHora = hora % 10;
dezenaHora = hora / 10;
unidadeMinuto = minuto % 10;
dezenaMinuto = minuto / 10;
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 8); //Set DISPLAY 1 (top view from left to right)
shiftOut(dataPin, clockPin, LSBFIRST, ~num2[dezenaHora]); //Set the Hour (ten) .. part 2
shiftOut(dataPin, clockPin, LSBFIRST, ~num1[dezenaHora]); //Set the Hour (ten) .. part 1
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no digit
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no segment
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no segment
digitalWrite(latchPin, HIGH);
delayMicroseconds(500);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 4); //Set DISPLAY 2
shiftOut(dataPin, clockPin, LSBFIRST, ~num2[unidadeHora]); //Set the Hour (unit) .. part 2
shiftOut(dataPin, clockPin, LSBFIRST, ~num1[unidadeHora]); //Set the Hour (unit) .. part 1
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no digit
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no segment
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no segment
digitalWrite(latchPin, HIGH);
delayMicroseconds(500);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 2); //Set DISPLAY 3
shiftOut(dataPin, clockPin, LSBFIRST, ~num2[dezenaMinuto]); //Set the Minute (ten) .. part 2
shiftOut(dataPin, clockPin, LSBFIRST, ~num1[dezenaMinuto]); //Set the Minute (ten) .. part 1
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no digit
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no segment
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no segment
digitalWrite(latchPin, HIGH);
delayMicroseconds(500);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 1); //Set DISPLAY 4
shiftOut(dataPin, clockPin, LSBFIRST, ~num2[unidadeMinuto]); //Set the Minute (unit) .. part 2
shiftOut(dataPin, clockPin, LSBFIRST, ~num1[unidadeMinuto]); //Set the Minute (unit) .. part 1
digitalWrite(latchPin, HIGH);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no digit
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no segment
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no segment
digitalWrite(latchPin, HIGH);
delayMicroseconds(500);
hora++;
minuto++;
}
1er essai 8) .... rigoler pas trop
:D**
**
bon ...
j’allège au max mon code, qui ce résume à un simple compteur :
int clockPin = 8; // Pin 8 of Arduino connected in the pin 11 of 74HC595 (Clock)
int latchPin = 9; // Pin 9 of Arduino connected in the pin 12 of 74HC595 (Latch)
int dataPin = 10; // Pin 10 of Arduino connected in the pin 14 of 74HC595 (Data)
//---------------------------------------------------
int cc = 0;
//Digits Matrix - 0 a 9 ... part 1
byte num1[] = {
B00000000, // Zero
B11010000, // One
B10101000, // Two
B00100000, // Three
B00101000, // Four
B00101000, // Five
B00101000, // Six
B00000000, // Seven
B00101000, // Eight
B00101000, // Nine
};
//Digits Matrix - 0 a 9 ... part 2
byte num2[] = {
B11111111, // Zero
B00001100, // One
B01101110, // Two
B11111100, // Three
B00110001, // Four
B11011101, // Five
B10011111, // Six
B11110000, // Seven
B11111111, // Eight
B11111001, // Nine
};
void setup() {
pinMode(latchPin, OUTPUT); // Define the 3 digital pins as output
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
//---------------
void loop() {
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 8); //Set DISPLAY 1 (top view from left to right)
shiftOut(dataPin, clockPin, LSBFIRST, ~num1[cc]); //Set the Hour (ten) .. part 2
shiftOut(dataPin, clockPin, LSBFIRST, ~num2[cc]); //Set the Hour (ten) .. part 1
digitalWrite(latchPin, HIGH);
delay(1200);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no digit
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no segment
shiftOut(dataPin, clockPin, LSBFIRST, 0); //Set no segment
digitalWrite(latchPin, HIGH);
cc++;
if (cc == 10)
{
cc = 0;
}
}
ca marche non 8) 8)
Bonjour,
oui !
trimarco232:
Bonjour,
oui !
je pense contacter un fabriquant pour commercialiser ce genre d'afficheur ... c'est un juste milieu entre le 7 segments et le alphanumérique ... non ?
je pense contacter un fabriquant pour commercialiser ce genre d'afficheur
tu peux toujours réaliser quelque(s) prototypes et essayer de les vendre pour tester le marché !