Word clock

Dear all,

A few weeks ago i decided to make my own word clock with an Arduino.
yesterday i returned from wintersport and all my stuff got delivered.

somehow my leds won’t light up. the led strip has worked when i got it hooked up on my arduino only, but rebooted after 19 leds due to lack of power since the leds would drain the usb port. after i hooked it up to my 5v powersupply the strip woundt work at all anymore.

so this what i got:
WS2812B (30 leds per meter) 3 meter
5V 6A powersupply ( i measure 6V on the strip though)
Arduino MEGA 2560

and this is how i got everything hooked up: (please ignore the

and this is the code i use for testing:
#include <Adafruit_NeoPixel.h>

#define PIN 6

// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic ‘v1’ (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(90, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
strip.begin();
strip.show(); // Initialize all pixels to ‘off’

}

void loop() {
// Some example procedures showing how to display to the pixels:
colorWipe(strip.Color(255, 0, 0), 50); // Red
colorWipe(strip.Color(0, 255, 0), 50); // Green
colorWipe(strip.Color(0, 0, 255), 50); // Blue

// Send a theater pixel chase in…
theaterChase(strip.Color(127, 127, 127), 50); // White
theaterChase(strip.Color(127, 0, 0), 50); // Red
theaterChase(strip.Color( 0, 0, 127), 50); // Blue

rainbow(20);
rainbowCycle(20);
theaterChaseRainbow(50);
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}

void rainbow(uint8_t wait) {
uint16_t i, j;

for(j=0; j<256; j++) {
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i+j) & 255));
}
strip.show();
delay(wait);
}
}

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
uint16_t i, j;

for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}

//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
for (int j=0; j<10; j++) { //do 10 cycles of chasing
for (int q=0; q < 3; q++) {
for (int i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, c); //turn every third pixel on
}
strip.show();

delay(wait);

for (int i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, 0); //turn every third pixel off
}
}
}
}

//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
for (int j=0; j < 256; j++) { // cycle all 256 colors in the wheel
for (int q=0; q < 3; q++) {
for (int i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, Wheel( (i+j) % 255)); //turn every third pixel on
}
strip.show();

delay(wait);

for (int i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, 0); //turn every third pixel off
}
}
}
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
if(WheelPos < 85) {
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
} else if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}

You seem to be putting 5 (or maybe 6) volts into the Arduino 5 volt output pin. I don't know what the effect of that would be but it feels wrong. What happens if you power the Arduino from USB as normal, power the LEDs from the external supply and join the GNDs ?

UKHeliBob:
You seem to be putting 5 (or maybe 6) volts into the Arduino 5 volt output pin. I don't know what the effect of that would be but it feels wrong. What happens if you power the Arduino from USB as normal, power the LEDs from the external supply and join the GNDs ?

some random leds light up in random colors
leds 2,3,4 light up white(ish)
leds 9,11,12 are blue.

eventhough i still measure 6V all over the strip.

Have you tried the Adafruit simple example program ?
Why have you got a resistor in the data line ?

Random colours?

Check you connections very carefully. Leads should be fairly short. That resistor should be directly on the LED strip, not at the Arduino end.

If the power supply really is producing 6V, put a power diode (1N4001 etc.) between it and the Arduino.

UKHeliBob:
Have you tried the Adafruit simple example program ?
Why have you got a resistor in the data line ?

you mean the strandtest? yes, no result.

you mean the strandtest? yes, no result.

I actually meant the example named simple

// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library

#include <Adafruit_NeoPixel.h>
#include <avr/power.h>

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN            6

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      16

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 500; // delay for half a second

void setup() {
  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
  // End of trinket special code

  pixels.begin(); // This initializes the NeoPixel library.
}

void loop() {

  // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.

  for(int i=0;i<NUMPIXELS;i++){

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    pixels.setPixelColor(i, pixels.Color(0,150,0)); // Moderately bright green color.

    pixels.show(); // This sends the updated pixel color to the hardware.

    delay(delayval); // Delay for a period of time (in milliseconds).

  }
}

All it does is to turn all of the LEDs on with a fixed colour, which you can change in the code, but it would prove that the wiring is correct and that all of the LEDs work.

okay guys,

i cut up my ledstrip in to pieces of 10 leds and hooked it up to my arduino. guess what it works again. i think im going to ditch the powersupply.

now i am trying to actually get my code together… i want to use FASTLED with a IF construction (still need to figure out how to get my RTC module working though).

but when i do a blink test my leds stay green when they should be off (0,0,0). does anyone have a clue?

#include “FastLED.h”

// How many leds in your strip?
#define NUM_LEDS 20

// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
#define DATA_PIN 6
#define CLOCK_PIN 13

// Define the array of leds
CRGB leds[NUM_LEDS];

void setup() {

FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
}

void loop() {

for(int i = 0;i < NUM_LEDS;i++)
leds = CRGB::Blue;

  • FastLED.show();*

  • delay(500);*

  • for(int i = 0;i < NUM_LEDS;i++)*
    _ leds = CRGB(0,0,0);_
    * FastLED.show();*
    * delay(500);*
    }

I am willing to bet that the code that you tried does not look like the code in your post above. Did you read this before posting a programming question ?

UKHeliBob:
I am willing to bet that the code that you tried does not look like the code in your post above. Did you read this before posting a programming question ?

sorry i think i still had some old code in my ctrl+c
this is what i have now, and still got the same result.

#include "FastLED.h"

// How many leds in your strip?
#define NUM_LEDS 20

// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN.  For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
#define DATA_PIN 6
#define CLOCK_PIN 13

// Define the array of leds
CRGB leds[NUM_LEDS];

void setup() { 
    
      FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
    }

void loop() { 

 for(int i = 0;i < NUM_LEDS;i++)
 leds[i] = CRGB(0,0,250);
 FastLED.show();
 delay(500);

 for(int i = 0;i < NUM_LEDS;i++)
 leds[i] = CRGB(0,0,0);
 FastLED.show();
 delay(500);
}

it doesnt happen when i do the Adafruit strandtest....

i dont get it :S

okay i got it working with Adafruit neopixel...

Can you please give a link to the LED strip that it did not work with ?

UKHeliBob:
Can you please give a link to the LED strip that it did not work with ?

this is the led strip that i use at the moment.

http://www.ebay.com/itm/281454903395?_trksid=p2060353.m2749.l2649&var=580493148356&ssPageName=STRK%3AMEBIDX%3AIT

btw i am running in to a new problem. as soon as i upload the program below, my RTC goes off. so i have my DS3231 hooked up on my arduino (VCC > ardcuino 3.3V, GND > arduino GND, SDA and SDL to arduino SDA/SDL).

#include "Wire.h"
#define DS3231_I2C_ADDRESS 0x68
// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
  return( (val/10*16) + (val%10) );
}
// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return( (val/16*10) + (val%16) );
}
void setup()
{
  Wire.begin();
  Serial.begin(9600);
  // set the initial time here:
  //DS3231 seconds, minutes, hours, day, date, month, year
  setDS3231time(30,42,22,1,16,3,15);
}
void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte
dayOfMonth, byte month, byte year)
{
  // sets time and date data to DS3231
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set next input to start at the seconds register
  Wire.write(decToBcd(second)); // set seconds
  Wire.write(decToBcd(minute)); // set minutes
  Wire.write(decToBcd(hour)); // set hours
  Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday)
  Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31)
  Wire.write(decToBcd(month)); // set month
  Wire.write(decToBcd(year)); // set year (0 to 99)
  Wire.endTransmission();
}
void readDS3231time(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
  Wire.beginTransmission(DS3231_I2C_ADDRESS);
  Wire.write(0); // set DS3231 register pointer to 00h
  Wire.endTransmission();
  Wire.requestFrom(DS3231_I2C_ADDRESS, 7);
  // request seven bytes of data from DS3231 starting from register 00h
  *second = bcdToDec(Wire.read() & 0x7f);
  *minute = bcdToDec(Wire.read());
  *hour = bcdToDec(Wire.read() & 0x3f);
  *dayOfWeek = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month = bcdToDec(Wire.read());
  *year = bcdToDec(Wire.read());
}
void displayTime()
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
  &year);
  // send it to the serial monitor
  Serial.print(hour, DEC);
  // convert the byte variable to a decimal number when displayed
  Serial.print(":");
  if (minute<10)
  {
    Serial.print("0");
  }
  Serial.print(minute, DEC);
  Serial.print(":");
  if (second<10)
  {
    Serial.print("0");
  }
  Serial.print(second, DEC);
  Serial.print(" ");
  Serial.print(dayOfMonth, DEC);
  Serial.print("/");
  Serial.print(month, DEC);
  Serial.print("/");
  Serial.print(year, DEC);
  Serial.print(" Day of week: ");
  switch(dayOfWeek){
  case 1:
    Serial.println("Sunday");
    break;
  case 2:
    Serial.println("Monday");
    break;
  case 3:
    Serial.println("Tuesday");
    break;
  case 4:
    Serial.println("Wednesday");
    break;
  case 5:
    Serial.println("Thursday");
    break;
  case 6:
    Serial.println("Friday");
    break;
  case 7:
    Serial.println("Saturday");
    break;
  }
}
void loop()
{
  displayTime(); // display the real-time clock data on the Serial Monitor,
  delay(1000); // every second
}

meanduck:
my RTC goes off.

Hi, what do you mean "goes off"? The little power led on the RTC goes off?

PS. you could shorten your code a little, like this:

void displayTime()
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  char buff[32];
  char dow[7][10] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
  &year);
  // send it to the serial monitor
  sprintf(buff, "%02d:%02d:%02d %02d/%02d/20%02d %s", hour, minute, second, dayOfMonth, month, year, dow[dayOfWeek-1]);
  Serial.println(buff);
}

(Compiles OK but not tested...)

PaulRB:
Hi, what do you mean "goes off"? The little power led on the RTC goes off?

PS. you could shorten your code a little, like this:

void displayTime()

{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year;
  char buff[32];
  char dow[7][10] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
  // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month,
  &year);
  // send it to the serial monitor
  sprintf(buff, "%02d:%02d:%02d %02d/%02d/20%02d %s", hour, minute, second, dayOfMonth, month, year, dow[dayOfWeek-1]);
  Serial.println(buff);
}



(Compiles OK but not tested...)

yes, as soon as i upload the program the powerled on the RTC goes off. and i do not get any lines on my serial monitor

when i use you code the same still happens.

meanduck:
yes, as soon as i upload the program the powerled on the RTC goes off. and i do not get any lines on my serial monitor

when i use you code the same still happens.

My code was not intended to fix your problem, just to shorten it once the problem was solved.

Sounds like it could be a short. Use your multimeter to check how much current is drawn after sketch upload.

Or your rtc is faulty or damaged. Is this the first time you have tested it?

Can you post a schematic or clear photo?

i still measure 3.3V when the LED of the RTC goes off.

btw, i recieved my RTC damaged on the pin side. it snapped there. thats why i soldered it to the holes on the other side. maybe that is the problem.

does the mega has a built in time function? maybe i can use it for now to proceed with my coding?

I would get another rtc module.

No, mega does not really have a built-in clock function. However, I believe there is a library that simulates an rtc, but the correct time would have to be set each time you power up, reset or upload a sketch. This may be ok for testing.

PaulRB:
I would get another rtc module.

No, mega does not really have a built-in clock function. However, I believe there is a library that simulates an rtc, but the correct time would have to be set each time you power up, reset or upload a sketch. This may be ok for testing.

thanks for you answer Paul!

the supplier sends me a new RTC :slight_smile:

in the meantime i have clock (hardware) almost ready :smiley:

i there a way to put one piece of code in one int like word?

to light up the first 2 words "Het is" (Dutch for "It is") i need to use this code, but this would make the code ridiculously long.

 //het.is
  strip.setPixelColor(0, 255, 255, 255);  
  strip.setPixelColor(1, 255, 255, 255); 
  strip.setPixelColor(2, 255, 255, 255);
  strip.setPixelColor(5, 255, 255, 255); 
  strip.setPixelColor(6, 255, 255, 255); 

strip.show();