/////////////////////////////////////////////////////////////////////
// Programme ARDUINO pour l'éclairage avec LED WS2812 //
// Commande en DCC et/ou Analogique //
// //
// Paramètrage via le port Série //
// //
// UAICF Nevers-Vauzelles //
// http://modelisme58.fr //
// //
// Octobre 2025 //
// Version 1.1 //
// //
// Plusieurs animations disponibles //
// //
/////////////////////////////////////////////////////////////////////
#define Emulateur_WOKWI
// *** Librairies nécessaires ***
// *** Bibliothèque à installer : http://mrrwa.org ou http://sourceforge.net/projects/mrrwa/files/MRRwA-2011-12-31.zip/download
#include <NmraDcc.h> // DCC
#include <EEPROM.h> // Gestion de la mémoire
#include <Bounce2.h> // Gestion des boutons à levier
#include <FastLED.h> // Gestion bandeau LED WS2812
NmraDcc Dcc ; // DCC
DCC_MSG Packet ; // DCC
const char Date_Compilation[] = __DATE__;
#include "configuration.h"
#include "programme.h"
#include "programmeAnimations.h"
#include "dcc.h"
#include "portserie.h"
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
void setup()
{
Serial.begin (9600);
Serial.println(F("UAICF 58 - http://modelisme58.free.fr"));
Serial.println(Date_Compilation);
Serial.println(F("Decodeur LED WS2812 - V1.0"));
Serial.print(F("Commande Analogique, DCC, Port COM et Centrale "));
TypeCentrale();
ConfigurationBornes();
Configuration();
Serial.print(F("$O")); Serial.println(ProgrammeNum);
FastLED.addLeds<TYPE_LED, Broche_Bandeau1, GRB>(Led_Bandeau1, Nb_LED_Bandeau1);
FastLED.addLeds<TYPE_LED, Broche_Bandeau2, GRB>(Led_Bandeau2, Nb_LED_Bandeau2);
FastLED.setMaxPowerInVoltsAndMilliamps(5, 500); // Limite de courant (optionnel mais recommandé)
FastLED.clear();
FastLED.show();
Dcc.init( MAN_ID_DIY, 10, CV29_ACCESSORY_DECODER | CV29_OUTPUT_ADDRESS_MODE, 0 ); // Appel de la fonction initiale pour recevoir les adresses DCC
pinMode(2, INPUT_PULLUP); // Interruption 0 - Ne pas oublier de mettre une résistance de 10 k raccordée au +5 Volts)
#ifdef Serial_DEBUG_Serie
Serial.println(F("--- Fin Initialisation ---"));
#endif
}
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
void loop()
{
Dcc.process(); // Commande en mode DCC
GestionBoutons();
if (ModeEffetAleatoire1) EffetAleatoire1();
if (ModeEffetAleatoire2) EffetAleatoire2();
if (Mode_Effet_Animation) Animation();
}Ruban N°1
Ruban N°2
Bouton A0 : On/Off toutes les LED
Bouton A1 : Commande Aléatoire Ruban N°1
Bouton A3 : Commande Animation Ruban N°1
Bouton A2 : Commande Aléatoire Ruban N°2
Bouton A4 : On/Off Led N°1
Bouton A5 : On/Off Led N°2
Gestion Led WS2812