Hi All, I am having some issues with the code for this word clock.

Hi All,

I am having some issues with the code for this word clock. I’m using an RTC breakout to tell the time, and a 121 LED long WS2812 strip snaked around as the picture shows (I started at 1 in the picture and realize that Arduino starts at 0, stupid MATLAB). I’ve written a loop for the minutes, and it works well for the most part - it reads the time from the clock, and outputs the correct LEDs. My problem is when it’s time to move to the next set of words, the previous set does not turn off. Any help is appreciated! Here is my code:

#include <FastLED.h>
#include <Wire.h>
#include “RTClib.h”
#define LED_PIN 7
#define NUM_LEDS 121

CRGBArray<NUM_LEDS>leds;
RTC_DS1307 rtc;

void setup() {
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
Serial.begin(57600);
if (! rtc.begin()) {
Serial.println(“Couldn’t find RTC”);
while (1);
}

if (! rtc.isrunning()) {
Serial.println(“RTC is NOT running!”);
// following line sets the RTC to the date & time this sketch was compiled
rtc.adjust(DateTime(F(DATE), F(TIME)));
// This line sets the RTC with an explicit date & time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}

}

void loop() {
DateTime now = rtc.now();
int mytimemin=now.minute();
int timehr=now.hour();

int ITSa =0;
int ITSb =2;
int ONEa =109;
int ONEb =111;
int THREEa= 99;
int THREEb =103;
int FOURa =110;
int FOURb =113;
int FIVEa1= 29;
int FIVEb1= 32;
int FIVEa2 =84;
int FIVEb2= 87;
int SIXa =104;
int SIXb =106;
int SEVENa= 45;
int SEVENb =49;
int EIGHTa= 94;
int EIGHTb= 98;
int NINEa =80;
int NINEb =83;
int TENa1 =18;
int TENb1= 20;
int TENa2 =74;
int TENb2 =76;
int ELEVENa= 88;
int ELEVENb= 94;
int NOONa= 51;
int NOONb= 54;
int MIDNIGHTa =66;
int MIDNIGHTb =73;
int A= 4;
int HALFa =6;
int HALFb =9;
int QUARTERa =11;
int QUARTERb =17;
int TWENTYa= 22;
int TWENTYb= 27;
int OCLOCKa= 115;
int OCLOCKb= 120;
int PASTa= 34;
int PASTb= 37;
int TILa= 38;
int TILb =40;

// ALWAYS ON
leds(ITSa,ITSb)=CRGB::Red;

// THE FOLLOWING CODE DESCRIBES THE MINUTES
if (mytimemin>57 && mytimemin<2){
//on the hour
}
else if (mytimemin>2 && mytimemin<8){
leds(FIVEa1,FIVEb1)=CRGB::Red;
leds(PASTa,PASTb)= CRGB::Red; }

else if (mytimemin>7 && mytimemin<13){
  leds(TENa1,TENb1)=CRGB::Red;
  leds(PASTa,PASTb)= CRGB::Red; }


else if (mytimemin>12 && mytimemin<18){
  leds(A,A)= CRGB::Red;
  leds(QUARTERa,QUARTERb)=CRGB::Red;
  leds(PASTa,PASTb)= CRGB::Red;  }


else if (mytimemin>17 && mytimemin<23){
  leds(TWENTYa,TWENTYb)= CRGB::Red;
  leds(PASTa,PASTb)= CRGB::Red;   }


else if (mytimemin>22 && mytimemin<28){
  leds(TWENTYa,TWENTYb)= CRGB::Red;
  leds(FIVEa1,FIVEb1)=CRGB::Red;
  leds(PASTa,PASTb)= CRGB::Red;  }

else if (mytimemin>27 && mytimemin<33){
  leds(HALFa,HALFb)= CRGB::Red;
  leds(PASTa,PASTb)= CRGB::Red;  }


else if (mytimemin>32 && mytimemin<38){
  leds(TWENTYa,TWENTYb)= CRGB::Red;
  leds(FIVEa1,FIVEb1)=CRGB::Red;
  leds(TILa,TILb)= CRGB::Red;    }


else if (mytimemin>37 && mytimemin<43){
  leds(TWENTYa,TWENTYb)= CRGB::Red;
  leds(TILa,TILb)= CRGB::Red;    }


else if (mytimemin>42 && mytimemin<48){
  leds(A,A)= CRGB::Red;
  leds(QUARTERa,QUARTERb)=CRGB::Red;
  leds(TILa,TILb)= CRGB::Red;    }

else if (mytimemin>47 && mytimemin<53){
  leds(TENa1,TENb1)=CRGB::Red;
  leds(TILa,TILb)= CRGB::Red;    }


else if (mytimemin>52 && mytimemin<58){
  leds(FIVEa1,FIVEb1)=CRGB::Red;
  leds(TILa,TILb)= CRGB::Red;    }

  FastLED.show();        

}

You never clear out the old colors - after a show you probably want to do something like leds(0,NUM_LEDS-1) = CRGB::Black;

@Daniel_Garcia thank you for the quick response! I’ll give this a try this afternoon