I'm fairly new to working and programming with arduinos. The project I am working on is a digital clock which uses a string of WS2812
leds to light up the correct numbers. Each digit consists of 7 leds and there are two 'colon' leds between the second and third digits. I am using the FastLED
library to try to program the code. I am able to make the leds light up such that all four digits are the same number (four consecutive 5's). However, the second I try to have it display multiple different numbers, everything goes south quickly. Here are some pictures of my current results:
55:55. I can create this with any number 0-9.
Should be 12:34.
Here is the code that I'm working with so far:
#include <RTClib.h>
RTC_DS3231 rtc;
DateTime now;
#define NUM_LEDS 30
#define LED_PIN 6
CRGB leds[NUM_LEDS];
void setup() {
// put your setup code here, to run once:
Serial.begin(57600);
FastLED.addLeds<WS2812, LED_PIN>(leds, NUM_LEDS);
FastLED.clear();
}
void loop() {
// put your main code here, to run repeatedly:
const int ZERO[]={0,1,2,4,5,6};
const int ONE[]={2,6};
const int TWO[]={0,1,3,5,6};
const int THREE[]={1,2,3,5,6};
const int FOUR[]={2,3,4,6};
const int FIVE[]={1,2,3,4,5};
const int SIX[]={0,1,2,3,4,5};
const int SEVEN[]={2,5,6};
const int EIGHT[]={0,1,2,3,4,5,6};
const int NINE[]={2,3,4,5,6};
for(int i=0; i<sizeof(ONE);i++){
leds[ONE[i]]=CRGB::Red;
FastLED.show();
}
for(int i=0; i<sizeof(TWO);i++){
leds[TWO[i]+7]=CRGB::Red;
FastLED.show();
}
for(int i=0; i<sizeof(THREE);i++){
leds[THREE[i]+16]=CRGB::Red;
FastLED.show();
}
for(int i=0; i<sizeof(FOUR);i++){
leds[FOUR[i]+23]=CRGB::Red;
FastLED.show();
}
Can anyone explain what's going wrong? Any help would be greatly appreciated. Let me know if you need clarification!
FastLED.show();
after the lastfor
loopFastLED.clear();
in the set up so it at least gets cleared once when the program is uploaded.