Salut à toutes et tous,
J'ai déjà sollicité il y a quelques mois votre aide pour la conception d'un système très aléatoire et j'ai une nouvelle fois besoin d'éclaircir un peu mon affaire...
Voilà j'aimerai réaliser un chronomètre déclenché par un capteur (je pense mettre un capteur laser), affichant le temps en temps réel (je ne suis pas au centième près) sur une matrice LED dont je n'ai pas encore défini la taille mais j'ai des 8x32 sous la main que je peux assembler si besoin (j'en ai mis deux bout à bout pour l'occasion de toute façon je ne dépasserai jamais ce format : "8:88:888").
En farfouillant un peu j'ai trouvé quelques réponses pour avancer un peu là-dessus et j'ai un code qui me pose problème pour quelque chose qui va surement vous paraître anodin et il n'est pas complet encore je dois le perfectionner pour conserver le temps d'arrêt du chrono affiché sur la matrice et effacer seulement avec une commande de remise a zéro du chrono mais là n'est pas le sujet...
En fait je ne parviens pas à afficher mon temps sur l'écran constitué de la matrice LED... J'ai essayé de lire mon Port Série et l'afficher : Sans succès
J'ai essayé de créer des valeurs correspondant aux minutes, secondes, et millièmes puis de les afficher : Sans succès également...
Quelqu'un aurait-il une idée pour me débloquer la situation ?
Voici mon code atuel :
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif
// MATRIX DECLARATION:
// Parameter 1 = width of the matrix
// Parameter 2 = height of the matrix
// Parameter 3 = pin number (most are valid)
// Parameter 4 = matrix layout flags, add together as needed:
// NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT:
// Position of the FIRST LED in the matrix; pick two, e.g.
// NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
// NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal
// rows or in vertical columns, respectively; pick one or the other.
// NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed
// in the same order, or alternate lines reverse direction; pick one.
// See example below for these values in action.
// Parameter 5 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_GRBW Pixels are wired for GRBW bitstream (RGB+W NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(64, 8, 5,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);
const uint16_t colors[] = {
matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(255, 210, 0), matrix.Color(0, 0, 255), matrix.Color(255, 0, 255), matrix.Color(0, 255, 255), matrix.Color(255, 255, 255), matrix.Color(91, 68, 43), matrix.Color(0, 0, 0)
};
unsigned long MS;
unsigned long start;
int millitotl;
int secototl;
int minutotl;
int bouton = 4;
void setup() {
Serial.begin (115200); // Serial.begin (115200);
Serial.available();
pinMode (bouton, INPUT);
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(100);
matrix.setTextColor(matrix.Color(255, 0, 0));
}
void loop() {
int btn = digitalRead (bouton);
if (btn == HIGH)
{
start = millis();
}
MS = millis() - start;
millitot1 = (MS % 1000) / 1 ; // millieme to display
secotot1 = (MS / 1000) % 60 ; // second to display
minutot1 = (MS / 1000) / 60 ; // minute to display
Serial.print ((MS / 1000) / 60); // minutes
Serial.print (":");
Serial.print ((MS / 1000) % 60); // secondes
Serial.print (":");
Serial.println (MS % 1000); // millièmes
matrix.fillScreen(0); //Efface la matrice de LED
matrix.setTextColor(colors[6]); //Choix de la couleur numero 5 (0, 255, 255)
matrix.setCursor(0, 0); //Curseur en position 0,0 (1ere ligne, 1ere colonne)
matrix.print(minutotl ":" secototl ":" millitotl);
}
Et pour l'instant voici l'erreur que j'obtiens :
C:\Users\benja\OneDrive\Documents\Arduino\CHRONO_MATRICE\CHRONO_MATRICE.ino: In function 'void loop()':
CHRONO_MATRICE:64:3: error: 'millitot1' was not declared in this scope
millitot1 = (MS % 1000) / 1 ; // millieme to display
^~~~~~~~~
C:\Users\benja\OneDrive\Documents\Arduino\CHRONO_MATRICE\CHRONO_MATRICE.ino:64:3: note: suggested alternative: 'millitotl'
millitot1 = (MS % 1000) / 1 ; // millieme to display
^~~~~~~~~
millitotl
CHRONO_MATRICE:65:3: error: 'secotot1' was not declared in this scope
secotot1 = (MS / 1000) % 60 ; // second to display
^~~~~~~~
C:\Users\benja\OneDrive\Documents\Arduino\CHRONO_MATRICE\CHRONO_MATRICE.ino:65:3: note: suggested alternative: 'secototl'
secotot1 = (MS / 1000) % 60 ; // second to display
^~~~~~~~
secototl
CHRONO_MATRICE:66:3: error: 'minutot1' was not declared in this scope
minutot1 = (MS / 1000) / 60 ; // minute to display
^~~~~~~~
C:\Users\benja\OneDrive\Documents\Arduino\CHRONO_MATRICE\CHRONO_MATRICE.ino:66:3: note: suggested alternative: 'minutotl'
minutot1 = (MS / 1000) / 60 ; // minute to display
^~~~~~~~
minutotl
CHRONO_MATRICE:76:25: error: expected ')' before string constant
matrix.print(minutotl ":" secototl ":" millitotl);
^~~
exit status 1
'millitot1' was not declared in this scope
Voilà voilà, en espérant avoir été complet...
D'avance merci à toutes et tous.
Benjamin