EDIT: seems to be fixed by using Arduino 1.5.2 instead of 1.0.1
Hi,
I was trying to enhance a RGB led library I wrote some time ago as a first library I made.
When using it I get some curious results.
For some reason the sketch seems to reset itself but I can't figure out why...
When I run this sketch all is well but as soon as I uncomment the Serial.println(" "); in debugMyRGBvalues():
void debugMyRGBvalues() {
//Serial.print(myLEDstrip.RedVal);Serial.print(",");
//Serial.print(myLEDstrip.GreenVal);Serial.print(",");
//Serial.print(myLEDstrip.BlueVal);
Serial.println(" ");
}
the code will run upto else if (i==4) {
then starts over again in void setup()
void loop()
{
curMillis = millis();
if ((curMillis - prevMillis) > 1000) {
Serial.print("i=");Serial.print(i);Serial.print(" ");
if (i==0) {
myLEDstrip.SetRedLight(255);
Serial.print("Red ");
debugMyRGBvalues();
}
else if (i==1) {
myLEDstrip.SetGreenLight(255);
Serial.print("Green ");
debugMyRGBvalues();
}
else if (i==2) {
myLEDstrip.SetBlueLight(255);
Serial.print("Blue ");
debugMyRGBvalues();
}
else if (i==3) {
myLEDstrip.SetWhiteLight(255);
Serial.print("White ");
debugMyRGBvalues();
}
else if (i==4) {
myLEDstrip.LEDstripOFF();
Serial.print("Off ");
debugMyRGBvalues();
}
else if (i<10) {
myLEDstrip.SetRandomColour();
Serial.print("Random ");
debugMyRGBvalues();
}
else if (i<15) {
int RR = 111;
myLEDstrip.SetRGBColour(RR,50,200);
Serial.print("Set RGB ");
debugMyRGBvalues();
}
else if (i<20) {
//myLEDstrip.SetHSLColour(200,100,50);
Serial.print("Set HSL ");
debugMyRGBvalues();
}
else {
i=-1;
Serial.println("");
}
i++;
prevMillis = curMillis;
}
}
Same happens if I change int RR = 111;
to int RR = random(255);
And If I uncomment myLEDstrip.SetHSLColour(200,100,50);
To make a long story short: the sketch becomes very unpredictable and unreliable
It is probably a minor thing that causes this but I have no clue where to look...
I hope someone can shed some RGB light on this
LEDstrip.cpp (5.49 KB)
keywords.txt (184 Bytes)
LEDstrip.h (1.79 KB)
RGB_LEDstrip.ino (1.73 KB)