Led ''nixie" clock

Hi guys,

I am busy with a led nixie clock LED “Nixie” Display | Make:

Im using a single ws2812b led for each number (original code uses two led’s per digit). i built my clock with 4 lixie displays, so its basically 40 leds on a string. How can i change the code to accommodate the 40 led’s such that i have a static clock only showing hours and minutes ? Also using the ds3231 rtc. Attached is the code i modded so far.

#include <Adafruit_NeoPixel.h>    // https://github.com/adafruit/Adafruit_NeoPixel
#include <DS3231.h>               // http://www.rinkydinkelectronics.com/library.php?id=73    ACHTUNG: Dies ist NICHT die Bibliothek, die ueber den Bibliotheksverwalter eingebunden werden kann! Ggf. vorher die andere Bibliothek entfernen oder lokalen Speicherort angeben ("")

const uint8_t PIN = 7;       // Datenpin. ca. 220-470 Ohm Widerstand zusaetzlich!
const uint8_t DIGITS = 2;    // Anzahl Digits à 20 LEDs

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(DIGITS * 10, PIN, NEO_GRB + NEO_KHZ800);     // Konstruktor WS2812

struct RGB
{
  uint8_t red;
  uint8_t grn;
  uint8_t blu;
};

/*
 * @brief   Ausgabe einer Ziffer auf einerm Digit
 * @param   Digit (ab 0)
 *          Zahl (0..9)
 *          Farbe (RGB)
 * @return  none
 */
void OutDigit (uint8_t digit, uint8_t value, struct RGB* farbe)
{
  pixels.setPixelColor((digit * 10) + (value), pixels.Color (farbe->red, farbe->grn, farbe->blu));
 // pixels.setPixelColor((digit * 20) + (value * 2) + 1, pixels.Color (farbe->red, farbe->grn, farbe->blu));
}

/*
 * @brief   Ausgabe einer Zahl
 * @param   Zahl (0-65536)
 *          Farbe (RGB)
 *          Fuehrende Nullen anzeigen (0=nein, 1=ja)
 * @return  none
 */
void OutZahl (uint16_t value, struct RGB* farbe, uint8_t leadingZero)
{
  uint8_t pos=0;
  uint8_t i=0;

  for (i = 0; i <= 128; i++)
  {
    pixels.setBrightness(255 - i*2);
    pixels.show();
  }
  
  pixels.clear();   // alle Farbwerte loeschen

  if (((value >= 10000) || leadingZero) && DIGITS >= 5)    // Zehntausender
  {
    OutDigit (pos, (value / 10000) % 10, farbe);
    pos++;
  }
  
  if (((value >= 1000) || leadingZero) && DIGITS >= 4)    // Tausender
  {
    OutDigit (pos, (value / 1000) % 10, farbe);
    pos++;
  }
  
  if (((value >= 100) || leadingZero) && DIGITS >= 3)    // Hunderter
  {
    OutDigit (pos, (value / 100) % 10, farbe);
    pos++;
  }
  
  if (((value >= 10) || leadingZero) && DIGITS >= 2)    // Zehner
  {
    OutDigit (pos, (value / 10) % 10, farbe);
    pos++;
  }
  
  OutDigit (pos, value % 10, farbe);                    // Einer

  pixels.setBrightness(255);
  pixels.show();
}

void setup(){}

void loop()
{
  RGB farbe;
  DS3231  rtc(SDA, SCL);      // Init the DS3231 using the hardware interface
  Time zeit;

  pixels.begin();               // NeoPixel library initialisieren
  rtc.begin();                  // RTC initialisieren
  //rtc.setTime(12, 00, 0);     // Stellt RTC auf 12:00:00 (24-Stundenformat). Diesen Aufruf einmal ausfuehren (Kommentar entfernen, Zeit einstellen) und danach auskommentieren und erneut auf den Arduino uebertragen
  
  while (1)
  {
    zeit = rtc.getTime();             // Zeit auslesen
  
    farbe.red=250;                     // andere Farbe
    farbe.grn=0;
    farbe.blu=200;
    OutZahl (zeit.hour, &farbe, 1);      // Stunden ausgeben mit Default-Farbe
    delay(2500);

    
    farbe.red=10;                     // andere Farbe
    farbe.grn=80;
    farbe.blu=250;
    OutZahl (zeit.min, &farbe, 1);       // Minuten ausgeben
    delay(2500);
  }
}

clock_mod_try.ino (3.32 KB)

led-nixie_clock original.ino (3.17 KB)

Hi and welcome.

Please use the “Link” icon to post links, like this: LED “Nixie” Display | Make:

Also please post your code in your post between code tags, unless it is too long. Most forum members use phones & tablets to read the forum and can’t open .ino attachments.

Do you understand the German comments in the code?

OutZahl() seems to dim the display slowly - is that wanted?

The loop() contains several declarations, before the while(1), that should be moved into global scope and initialized once in setup(). The while(1) body should become the new loop() body. Do you understand what this means to the code?

Rewrite the body of loop() to update the display only when the time has changed. Then calculate the number for OutZahl() from hour*100 + minutes and call OutZahl() once.

Do be honest, i dont have lots of coding experience

Can you describe what's wrong with the code you have modded?

The code alternates minutes and seconds on 2 digits, wanted is a static hr:mn display on 4 digits.

Yes, thx, you put it very simple but thats the only thing i want

Try this (untested!)

#include <Adafruit_NeoPixel.h>    // https://github.com/adafruit/Adafruit_NeoPixel
#include <DS3231.h>               // http://www.rinkydinkelectronics.com/library.php?id=73    ACHTUNG: Dies ist NICHT die Bibliothek, die ueber den Bibliotheksverwalter eingebunden werden kann! Ggf. vorher die andere Bibliothek entfernen oder lokalen Speicherort angeben ("")

const uint8_t PIN = 7;       // Datenpin. ca. 220-470 Ohm Widerstand zusaetzlich!
const uint8_t DIGITS = 4;    // Anzahl Digits à 10 LEDs

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(DIGITS * 10, PIN, NEO_GRB + NEO_KHZ800);     // Konstruktor WS2812

DS3231  rtc(SDA, SCL);      // Init the DS3231 using the hardware interface
Time zeit;

void setup()
{
  pixels.begin();               // NeoPixel library initialisieren
  rtc.begin();                  // RTC initialisieren
  //rtc.setTime(12, 00, 0);     // Stellt RTC auf 12:00:00 (24-Stundenformat). Diesen Aufruf einmal ausfuehren (Kommentar entfernen, Zeit einstellen) und danach auskommentieren und erneut auf den Arduino uebertragen
}

void loop()
{
  zeit = rtc.getTime();             // Zeit auslesen
  pixels.clear();   // alle Farbwerte loeschen
  pixels.setPixelColor(00 + zeit.hour / 10, pixels.Color (250, 0, 200));
  pixels.setPixelColor(10 + zeit.hour % 10, pixels.Color (250, 0, 200));
  pixels.setPixelColor(20 + zeit.min / 10, pixels.Color (10, 80, 250));
  pixels.setPixelColor(30 + zeit.min % 10, pixels.Color (10, 80, 250));
  pixels.setBrightness(255);
  pixels.show();
  delay(1000);

}

Got it right thanx guys. Used a whole other code

Thanks for testing the code I took the time to fix for you and reporting back as to whether it worked or not. Great to know my time was not wasted. Please come again, it's been a pleasure working with you.