Hi all,
I had a strip of Neopixel laying around and thought it might be nice to do something with them. The strip is 65 pixels long so I thought I might have a go at making a neopixel clock with one colour for seconds, one for minutes and one for hours. Maybe even laser cut a simple case to present it in.
The problem is with the code. Well actually the problem is probably me !! LOL.
The code I have written is giving compile errors. I have tried a couple of things like changing case and swapping round the includes but I still can not get it to compile. The code is as follows,
'#include "neopixel/neopixel.h"
'#include "application.h"
void setup() {
// IMPORTANT: Set Pin, number of types and NeoPixel model
'#define NEOPIXEL_PIN D2
'#define NEOPIXEL_COUNT 60
'#define NEOPIXEL_TYPE WS2812B
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NEOPIXEL_COUNT, NEOPIXEL_PIN, NEOPIXEL_TYPE);
Spark.syncTime();
Time.zone(+1);
//Time.setTime(1410302158);
strip.setBrightness(30);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
Serial.begin(9600);
}
void loop() {
int hour = Time.hourFormat12();
int min = Time.minute();
int sec = Time.second();
// seconds
Serial.print(sec);
strip.setPixelColor(sec,50,50,50);
strip.show();
This gives the error,
In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from neopixel/neopixel.h:42,
from neopixel/neopixel.cpp:39:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
'#warning "Defaulting to Release Build"
^
In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from neopixel/neopixel.h:42,
from neopixel_clock.cpp:6:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
'#warning "Defaulting to Release Build"
^
neopixel_clock.cpp: In function 'void setpixeltime()':
neopixel_clock.cpp:9:5: error: 'strip' was not declared in this scope
^
neopixel_clock.cpp:9:25: error: 'sec' was not declared in this scope
I get the warnings, they are fine, the code is not finished yet so there are still unused variables. It is the strip, not declared etc. It is as if the library is not added or I am not calling the function correctly. I took the function from some working code so I donât think that is it. I have also removed and the replaced the neopixel library to see if that makes a difference.
It doesnât.
Any help greatly appreciated.
Julian