Incorrect LED colors with BlinkM_setRGB()
Programming: A simple Arduino sketch that implements a linear brightness ramp (0 to 255), one color at a time, using BlinkM_setRGB(). At any moment, one of the colors should be ON and the other two should be OFF. Each brightness level is held for 0.5 second. Source code is below.
Problem: (1) As each ON color ramps up, I see occasional bright flashes (0.5 - 2 seconds long) of one of the OFF colors. Less frequently, both of the OFF colors flash at the same time. (2) Although the ON color follows the brightness ramp most of the time, I also see the ON color dimming, going off, or brightening for 0.5 - 1 second, after which it returns to the programmed ramp.
Other info: (1) I have two brand new BlinkM units. Both BlinkM's show the same behavior. (2) Leaving DEBUG_PRINT undefined does not affect the LED behavior.
Using Arduino Diecimilia and Arduino environment software 0011, with BlinkM plugged directly into analog pins 2-5.
-----------------------------------------------------------------------
/*
* BlinkM Linear Test
*/
#include "Wire.h"
#include "BlinkM_funcs.h"
#define BLINKM_ARDUINO_POWERED 1
#define BLINKM_ADDR 0x09
#define DELAY_MS 500
#define DEBUG_PRINT
void setup()
{
byte rc, addr;
if (BLINKM_ARDUINO_POWERED)
BlinkM_beginWithPower();
else
BlinkM_begin();
BlinkM_setAddress (BLINKM_ADDR); // comment out to not set address
Serial.begin(19200);
rc = BlinkM_checkAddress( BLINKM_ADDR );
if (rc == -1)
Serial.println("\r\nno response");
else if (rc == 1)
Serial.println("\r\naddr mismatch");
addr = BlinkM_getAddress(BLINKM_ADDR);
Serial.print("Addr=");
Serial.println(addr,DEC);
}
void loop()
{
byte r, g, b, n;
int c;
for (n=0; n<3><256>);
Serial.print(b,DEC);
Serial.println();
#endif
BlinkM_setRGB(BLINKM_ADDR, r, g, b);
delay(DELAY_MS);
}
}
}
------------------------------------------------
Sample output from serial console:
rgb=240,0,0
rgb=245,0,0
rgb=250,0,0
rgb=255,0,0
rgb=0,0,0
rgb=0,5,0
rgb=0,10,0
rgb=0,15,0
rgb=0,20,0
Problem: (1) As each ON color ramps up, I see occasional bright flashes (0.5 - 2 seconds long) of one of the OFF colors. Less frequently, both of the OFF colors flash at the same time. (2) Although the ON color follows the brightness ramp most of the time, I also see the ON color dimming, going off, or brightening for 0.5 - 1 second, after which it returns to the programmed ramp.
Other info: (1) I have two brand new BlinkM units. Both BlinkM's show the same behavior. (2) Leaving DEBUG_PRINT undefined does not affect the LED behavior.
Using Arduino Diecimilia and Arduino environment software 0011, with BlinkM plugged directly into analog pins 2-5.
-----------------------------------------------------------------------
/*
* BlinkM Linear Test
*/
#include "Wire.h"
#include "BlinkM_funcs.h"
#define BLINKM_ARDUINO_POWERED 1
#define BLINKM_ADDR 0x09
#define DELAY_MS 500
#define DEBUG_PRINT
void setup()
{
byte rc, addr;
if (BLINKM_ARDUINO_POWERED)
BlinkM_beginWithPower();
else
BlinkM_begin();
BlinkM_setAddress (BLINKM_ADDR); // comment out to not set address
Serial.begin(19200);
rc = BlinkM_checkAddress( BLINKM_ADDR );
if (rc == -1)
Serial.println("\r\nno response");
else if (rc == 1)
Serial.println("\r\naddr mismatch");
addr = BlinkM_getAddress(BLINKM_ADDR);
Serial.print("Addr=");
Serial.println(addr,DEC);
}
void loop()
{
byte r, g, b, n;
int c;
for (n=0; n<3><256>);
Serial.print(b,DEC);
Serial.println();
#endif
BlinkM_setRGB(BLINKM_ADDR, r, g, b);
delay(DELAY_MS);
}
}
}
------------------------------------------------
Sample output from serial console:
rgb=240,0,0
rgb=245,0,0
rgb=250,0,0
rgb=255,0,0
rgb=0,0,0
rgb=0,5,0
rgb=0,10,0
rgb=0,15,0
rgb=0,20,0
1 person has this problem
I have this problem, too!
Tell me when someone solves it.
The more people who report this problem, the more it gets noticed.
The more people who report this problem, the more it gets noticed.
-
Inappropriate?For some reason, major portions of the source code were deleted by the discussion board software. I will e-mail the correct source code with this report.
I’m frustrated
-
Inappropriate?Tod suggested the following fix: "You can send 'BlinkM_setRGB()' while a script is playing and it will change color, but then continue playing the script. You can turn off the script in setup() by doing a 'BlinkM_stopScript(addr)' right after you connect
to a BlinkM."
After adding a call to 'BlinkM_stopScript(addr)' at the end of my setup() function, the BlinkM is working as I expected.
Thank you, Tod, for the quick diagnosis and solution.
I’m happy
1 person says
this solves the problem
Loading Profile...


