Horloge digitale : Différence entre versions
| (6 révisions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 1 : | Ligne 1 : | ||
| − | <pre>///////////////////////////////// | + | <pre> |
| + | ///////////////////////////////// | ||
// // | // // | ||
// Afficher des Pictos // | // Afficher des Pictos // | ||
| Ligne 21 : | Ligne 22 : | ||
/////////////////////////////////////////////////////////////////// | /////////////////////////////////////////////////////////////////// | ||
/* | /* | ||
| − | Matériel | + | </pre> |
| + | ==Matériel== | ||
| + | <pre> | ||
- un Wemos | - un Wemos | ||
| − | - une matrice de LED MAX7219. | + | - une matrice de LED MAX7219. |
- Quelques câbles dupont | - Quelques câbles dupont | ||
tutoriel disponible sur : http://wikidebrouillard.dokit.io/wiki/Afficher_des_pictos_sur_une_matrice_de_led_8X8 | tutoriel disponible sur : http://wikidebrouillard.dokit.io/wiki/Afficher_des_pictos_sur_une_matrice_de_led_8X8 | ||
| + | </pre> | ||
| − | + | ==Code Arduino== | |
| − | + | <pre> | |
| − | |||
#include "LedControl.h" | #include "LedControl.h" | ||
#include <ESP8266WiFi.h> | #include <ESP8266WiFi.h> | ||
| Ligne 426 : | Ligne 429 : | ||
} | } | ||
</pre> | </pre> | ||
| − | [[Fichier:Horloge.jpg | + | ==Resultat final avec une belle boite== |
| − | + | [[Fichier:Horloge.jpg|600px|link=https://www.facebook.com/pages/category/Dance---Night-Club/Les-Tritons-1627403894182122/]] | |
Version actuelle datée du 21 janvier 2019 à 23:31
///////////////////////////////// // // // Afficher des Pictos // // Sur une matrice de LED 8X8 // // // ///////////////////////////////// /////////////////////////////////////////////////////////////////// // BROCHAGE // // _________________ // // / D1 mini \ // // - |[ ]RST TX[ ]| - // // - |[ ]A0 RX[ ]| - // // - |[ ]D0 D1[ ]| - // // Din - |[X]D5 D2[ ]| - // // CLK - |[X]D6 D3[ ]| - // // CS - |[X]D7 D4[ ]| LED_BUILTIN // // - |[ ]D8 GND[X]| - // // - |[X]3V3 . 5V[ ]| - // // | +---+ | // // |_______|USB|_______| // /////////////////////////////////////////////////////////////////// /*
Matériel
- un Wemos - une matrice de LED MAX7219. - Quelques câbles dupont tutoriel disponible sur : http://wikidebrouillard.dokit.io/wiki/Afficher_des_pictos_sur_une_matrice_de_led_8X8
Code Arduino
#include "LedControl.h"
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <Time.h>
#define CS_broche D7
#define CLK_broche D6
#define DIN_broche D5
// Identifiant WIFI à inscrire en dur
const char* ssid = "G6_7499"; // Identifiant WiFi
const char* password = "gabriell"; // Mot de passe WiFi
int timezone = 3;
int dst = 0;
ESP8266WebServer server(80);
LedControl lc=LedControl(DIN_broche,CLK_broche,CS_broche,4);
// On défini un ensemble de matrice de led "lc".
// Dans l'ordre, on branche les broches Din sur la broche D5, CLK sur D6, CS sur D7.
// le dernier chiffre indique le nombre de matrice de LED (il peut y en avoir jusqu'à 8).
// ici on n'en a qu'une.
// Pour créer une image, il faut allumer ou éteindre certaines led
// Les valeurs qui gèrent l'allumage de chaque LED sont dans un tableau (0 = led éteinte, 1 = Led Allulmée).
byte zero[]={
B00111110,
B00100010,
B00100010,
B00100010,
B00100010,
B00100010,
B00111110,
B00000000
};
byte un[]={
B00010000,
B00110000,
B01010000,
B10010000,
B00010000,
B00010000,
B00010000,
B00000000
};
byte deux[]={
B01110000,
B10001000,
B00001000,
B00010000,
B00100000,
B01000000,
B11111000,
B00000000
};
byte trois[]={
B11111000, //3
B00010000,
B00100000,
B00010000,
B00001000,
B10001000,
B01110000,
B00000000
};
byte quatre[]={
B00010000, //4
B00110000,
B01010000,
B10010000,
B11111000,
B00010000,
B00010000,
B00000000
};
byte cinq[]={
B11111000, //5
B10000000,
B11110000,
B00001000,
B00001000,
B10001000,
B01110000,
B00000000
};
byte six[]={
B00110000, //6
B01000000,
B10000000,
B11110000,
B10001000,
B10001000,
B01110000,
B00000000
};
byte sept[]={
B11111000, //7
B10001000,
B00001000,
B00010000,
B00100000,
B00100000,
B00100000,
B00000000
};
byte huit[]={
B01110000, //8
B10001000,
B10001000,
B01110000,
B10001000,
B10001000,
B01110000,
B00000000
};
byte neuf[]={
B01110000, //9
B10001000,
B10001000,
B01111000,
B00001000,
B00010000,
B01100000,
B00000000
};
void setup()
{
Serial.begin(115200);
lc.shutdown(0,false); // Allule la matrice de led
lc.setIntensity(0,1); // règle la luminosité (de 1 à 10)
lc.clearDisplay(0); // efface la matrice (éteint toute les les led).
lc.shutdown(1,false); // Allule la matrice de led
lc.setIntensity(0,1); // règle la luminosité (de 1 à 10)
lc.clearDisplay(0); // efface la matrice (éteint toute les les led).
lc.clearDisplay(1); // efface la matrice (éteint toute les les led).
lc.shutdown(2,false); // Allule la matrice de led
lc.setIntensity(0,1); // règle la luminosité (de 1 à 10)
lc.clearDisplay(0); // efface la matrice (éteint toute les les led).
lc.shutdown(3,false); // Allule la matrice de led
lc.setIntensity(0,1); // règle la luminosité (de 1 à 10)
lc.clearDisplay(0); // efface la matrice (éteint toute les les led).
// On démarre le moniteur série , afin d'avoir des infos sur l’état du serveur et récupérer l'adresse IP de la carte.
// Démarrage de la connection WIFI
WiFi.begin(ssid, password);
// debug - affichage dans moniteur série
Serial.println("");
// on attend d’être connecté au WiFi avant de continuer
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
configTime(timezone * 3600, dst * 0, "pool.ntp.org", "time.nist.gov");
Serial.println("\nWaiting for time");
while (!time(nullptr)) {
Serial.print(".");
delay(1000);
}
Serial.println("");
// on affiche l'adresse IP attribuée pour le serveur WEB
Serial.println("");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
// on definit les points d’entrée (les URL à saisir dans le navigateur web) et on affiche un simple texte
server.on("/", [](){
server.send(200, "text/plain", "Bienvenue sur le serveur de temps");
});
// on démarre le serveur web
server.begin();
}
// Prendre les valeurs dans les tableaux et les afficher
void fonction0(int j)
{
for (int i = 0; i < 8; i++)
{
lc.setRow(j,i,zero[i]);
}
}
void fonction1(int j)
{
for (int i = 0; i < 8; i++)
{
lc.setRow(j,i,un[i]);
}
}
void fonction2(int j)
{
for (int i = 0; i < 8; i++)
{
lc.setRow(j,i,deux[i]);
}
}
void fonction3(int j)
{
for (int i = 0; i < 8; i++)
{
lc.setRow(j,i,trois[i]);
}
}
void fonction4(int j)
{
for (int i = 0; i < 8; i++)
{
lc.setRow(j,i,quatre[i]);
}
}
void fonction5(int j)
{
for (int i = 0; i < 8; i++)
{
lc.setRow(j,i,cinq[i]);
}
}
void fonction6(int j)
{
for (int i = 0; i < 8; i++)
{
lc.setRow(j,i,six[i]);
}
}
void fonction7(int j)
{
for (int i = 0; i < 8; i++)
{
lc.setRow(j,i,sept[i]);
}
}
void fonction8(int j)
{
for (int i = 0; i < 8; i++)
{
lc.setRow(j,i,huit[i]);
}
}
void fonction9(int j)
{
for (int i = 0; i < 8; i++)
{
lc.setRow(j,i,neuf[i]);
}
}
void loop()
{
server.handleClient();
time_t now;
struct tm * timeinfo;
time(&now);
timeinfo = localtime(&now);
Serial.println(timeinfo->tm_hour);
Serial.println(timeinfo->tm_min);
int minutes=timeinfo->tm_min;
int uniteminute = minutes % 10;
int dizaineminute = minutes / 10 % 10;
int heures=timeinfo->tm_hour;
int uniteheure = (heures % 10)-2; //car heure anglaise
int dizaineheure = heures / 10 % 10;
/*Serial.println(dizaineheure);
Serial.println(dizaineminute);
Serial.println(uniteheure);
Serial.println(uniteminute);*/
switch(dizaineheure) {
case 0 :
fonction0(0);
break;
case 1 :
fonction1(0);
break;
case 2 :
fonction2(0);
break;
}
switch(uniteheure) {
case 0 :
fonction0(0);
break;
case 1 :
fonction1(1);
break;
case 2 :
fonction2(1);
break;
case 3 :
fonction3(1);
break;
case 4 :
fonction4(1);
break;
case 5 :
fonction5(1);
break;
case 6 :
fonction6(1);
break;
case 7 :
fonction7(1);
break;
case 8 :
fonction8(1);
break;
case 9 :
fonction9(1);
break;
}
switch(dizaineminute) {
case 0 :
fonction0(2);
break;
case 1 :
fonction1(2);
break;
case 2 :
fonction2(2);
break;
case 3 :
fonction3(2);
break;
case 4 :
fonction4(2);
break;
case 5 :
fonction5(2);
break;
}
switch(uniteminute) {
case 0 :
fonction0(3);
break;
case 1 :
fonction1(3);
break;
case 2 :
fonction2(3);
break;
case 3 :
fonction3(3);
break;
case 4 :
fonction4(3);
break;
case 5 :
fonction5(3);
break;
case 6 :
fonction6(3);
break;
case 7 :
fonction7(3);
break;
case 8 :
fonction8(3);
break;
case 9 :
fonction9(3);
break;
}
delay(1000);
}
