// MobaLedLib_ex1_blinker_welding.ino by Svein-Martin Holt, www.platelayer.com -- www.zityedge.com, april 2021 /* This Arduino sketch show how easy it is to use the MobaLedLib for blink and welding. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ On my new layout, the Zity Edge Layout, I use this library "everywhere" on the layout, for lighs and animation effects. The blink in this sketch is used on the roof top of some buldings to create a roof red flashing beacon, the welding effect are used in different factory shops to simulate welding. Both functions are defined in a single configuration line statement in the code. Its possible to trig the effect with buttons or variables, but in the example both effect runs continuesly. The sketch use adresseable WS2811, WS2812 LED-strips, where a single dataline is used to drive the different LED's, in addtion to the power for the LED-strip. The configuration can be done using a Excel spreadsheet that creates the configuration syntax, but you can also define it directly in the sketch. Check out the MobaLedLib on the net for more info: https://github.com/Hardi-St/MobaLedLib The MobaLedLb wiki: https://wiki.mobaledlib.de/doku.php The FastLED homepage: http://fastled.io/ The Adafruit Neopixel homepage: https://learn.adafruit.com/adafruit-neopixel-uberguide */ #define FASTLED_INTERNAL // Disable version number message in FastLED library (looks like an error) #include "FastLED.h" // The FastLED library must be installed #include "MobaLedLib.h" // Use the Moba Led Library #define NUM_LEDS 16 // Number of LEDs with some spare channels (Maximal 256 RGB LEDs could be used with MobaLedLib) #define LED_DO_PIN 2 // Pin D2 is connected to the LED stripe #define LED_NUM_BLINK 1 // Define LED number in string to blink, here the first LED, 1, physical LED number 2 #define LED_NUM_WELD 6 // Define LED number in string to simulate welding, here LED number 6, physical LED number 7 //******************************************************************* // *** Configuration array which defines the behavior of the LEDs *** MobaLedLib_Configuration() { // Blinker, 1 sec interval on first LED, 2 sec interval on second LED, 0.5 sec interval on third LED // LED: LED number in the stripe // | RGB channel // | | InCh: Input channel. Here the special input 1 is used which is always on // | | | Blink frequency, 1, 2 and 0.5 second // | | | | | | Blinker(LED_NUM_BLINK, C1, SI_1, 1 Sek) // C1: first RGB LED, Red Flashing LED Blinker(LED_NUM_BLINK + 1, C_GREEN, SI_1, 2 Sek) // C_GREEN: Green Flashing LED Blinker(LED_NUM_BLINK + 2, C3, SI_1, 0.5 Sek) // C3: Blue Flashing LED // Welding // LED: LED number in the stripe // | InCh: Input channel. Here the special input 1 is used which is always on // | | The different parameters is configured using the Excel sheet or can be found in the documentation // | | | RandWelding(LED_NUM_WELD, SI_1, 0, 10 Sek, 30 Sek, 6 Sek, 10 Sek) EndCfg // End of the configuration }; //******************************************************************* // LED Type and LED strip Color order #define LED_TYPE WS2811 #define COLOR_ORDER GRB // The Color order depends on the type of LED-strip, RGB or GRB CRGB leds[NUM_LEDS]; // Define the array of leds MobaLedLib_Create(leds); // Define the MobaLedLib instance LED_Heartbeat_C LED_Heartbeat(LED_BUILTIN); // Use the build in LED as heartbeat //---------- void setup() { //---------- // This function is called once to initialize the program // FastLED.addLeds(leds, NUM_LEDS); // Initialize the FastLED library } //--------- void loop() { //--------- // This function contains the main loop which is executed continuously // MobaLedLib.Update(); // Update the LEDs in the configuration FastLED.show(); // Show the LEDs (send the leds[] array to the LED stripe) LED_Heartbeat.Update(); // Update the heartbeat LED. This must be called periodically in the loop() function. }