Alors pour remédier à cet oubli, voici une petite mise à jour de la fabrication du minuteur LED (voir un-minuteur-base-led-multicolores.html).
Compte tenu du fait que le temps de match passe de 90s à 100s, il faut rajouter quelques LED.
La solution idéale consisterait à rajouter un digit complet devant les deux existants. On pourrait alors aller jusqu'à 999s de match (ou de tout ce qu'on veut chronométrer d'ailleurs).
Dans le but de réduire le budget et de se limiter au strict nécessaire, j'ai décidé d'opter pour le rajout d'un "1" supplémentaire. On gagne ainsi 20 LED, mais on se limite à 199s (ce qui est déjà pas mal)
Le matériel reste sinon le même, à 8 LED près. Le schéma électronique avec l'Arduino, le déclencheur et le bandeau de LED reste identique.
En revanche, le schéma des LED est différent. Le 1 est inséré devant les 2 autres digit (c'est un choix personnel, on aurait pu le câbler après...)
Il faut ensuite modifier le code pour prendre en compte les valeurs entre 91 et 100 qui n'étaient pas prévu dans le programme initial.
J'en ai profité pour rajouter des définitions de couleurs, des changements de couleur vers la fin du match et pendant la funny action (même s'il n'y en a pas cette année, on conserve cette possibilité)
// Mise à jour pour prise en comte du passage à 100s // suppression du temps de funny action // coupe 2018 : Robot Cities #include <Adafruit_NeoPixel.h> //#define FUNNY_ACTION // Which pin on the Arduino is connected to the NeoPixels? #define PIN_PIXELS 6 // How many NeoPixels are attached to the Arduino? #define NUMPIXELS 64 // how many pixels per branch of the digits #define NUM_PIX_PER_BRANCH 4 #define VAL_INIT 100 // the pin for launching counter #define PIN_LAUNCH 7 // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals. // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest // example for more information on possible values. Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN_PIXELS, NEO_GRB + NEO_KHZ800); // colors defined for lignhtened (or not) pixels uint32_t coul_on = pixels.Color(200, 200, 200); uint32_t coul_red = pixels.Color(200, 0, 0); uint32_t coul_off = pixels.Color(0, 0, 0); uint32_t coul_blu = pixels.Color(0, 0, 200); uint32_t coul_hi = pixels.Color(0, 0, 255); uint32_t coul_green = pixels.Color(0,150,0); int chiffres[10] = {0x77, 0x44, 0x3E, 0x6E, 0x4D, 0x6B, 0x7B, 0x46, 0x7F, 0x6F}; int go_counter = 1; int val_counter = VAL_INIT; // number of seconds void setup() { // put your setup code here, to run once: pixels.begin(); // This initializes the NeoPixel library. pinMode(PIN_LAUNCH, INPUT_PULLUP); // input is set as pullup to avoid having three wires Affiche(VAL_INIT, coul_green); // before start // set the data rate for the SoftwareSerial port } void loop() { // put your main code here, to run repeatedly: if (digitalRead(PIN_LAUNCH) == LOW) // button pressed go_counter = 1; // used as a RSFlipFlop if (digitalRead(PIN_LAUNCH) == HIGH) // button released go_counter = 0; // if stable switch if (go_counter == 0) Affiche(VAL_INIT, coul_green); else if (val_counter > 5) Affiche(val_counter, coul_on); // showing the number else if (val_counter > 0) Affiche(val_counter, coul_blu); // last 5 secondes in blue #ifdef FUNNY_ACTION else if (val_counter > -5) Affiche(0, coul_red); // during funny action #endif else Affiche(0, coul_on); // after funny action, everything is off if (go_counter) { val_counter--; // minus 1s delay(1000);// if no RTC, the delay must be calibrated to keep real timing } else val_counter = VAL_INIT; } void Affiche(int number, uint32_t color ) { uint32_t col; //color, on or off byte n_diz = (number / 10)%10; byte n_uni = number % 10; if (number > 199) return; // no lighting over 99 else { // the first "1" if (number >99) // "1" has to be lightened { for (int h = 0; h < 2*NUM_PIX_PER_BRANCH; h++)pixels.setPixelColor(h, color); } else { for (int h = 0; h < 2*NUM_PIX_PER_BRANCH; h++) pixels.setPixelColor(h, coul_off); } for (int i = 0; i < 7; i++) // each digit { // first dozens if ((1 << i) & chiffres[n_diz]) col = color; else col = coul_off; // if number is between 1 and 9, nothing is lightened for dozens if (number < 10 && number >0) col = coul_off; for (int j = 0; j < NUM_PIX_PER_BRANCH; j++) { pixels.setPixelColor(i * NUM_PIX_PER_BRANCH + j+2*NUM_PIX_PER_BRANCH, col); } // then units if ((1 << i) & chiffres[n_uni]) col = color; else col = coul_off; for (int j = 0; j < NUM_PIX_PER_BRANCH; j++) { pixels.setPixelColor(7 * NUM_PIX_PER_BRANCH + i * NUM_PIX_PER_BRANCH + j+2*NUM_PIX_PER_BRANCH, col); } } } pixels.show(); }
Et après ça, ça devrait le faire 😃
Salut!
RépondreSupprimerSympas le partage! Avec l'ajout de ce "1" sur l'afficheur vous pouvez aussi éventuellement afficher avec votre nombre de point marqué non ? =) Ainsi ce super afficheur peut faire d'une pierre deux coups! Tant que vous ne dépassez pas les 199 points ça devrait le faire =) Qu'en pensez vous? =)
Mike118 (de Robot-Maker)
C'est une bonne idée mais on va essayer de faire un peu plus original sur le panneau domotique, et en plus 199 points c'est largement en dessous de notre objectif ;-) ^^
Supprimer