Hello. I’m new here. I’m setting up controllable lights for some pumpkins and have two of these cool ShiftBar boards and a Satellite modules from macetech. I’m only running one of these for now for testing and I have something close to what I want, but I am getting unexpected flashes from other LEDs (channels) when trying to fade only one color. Here is my slightly modified code from macetech blog.
int datapin = 13; // DI
int latchpin = 12; // LI
int enablepin = 11; // EI
int clockpin = 10; // CIint fade = 3;
unsigned long SB_CommandPacket;
int SB_CommandMode;
int SB_BlueCommand;
int SB_RedCommand;
int SB_GreenCommand;void setup() {
pinMode(datapin, OUTPUT);
pinMode(latchpin, OUTPUT);
pinMode(enablepin, OUTPUT);
pinMode(clockpin, OUTPUT);Serial.begin(9600);
digitalWrite(latchpin, LOW);
digitalWrite(enablepin, LOW);}
void SB_SendPacket() {
SB_CommandPacket = SB_CommandMode & B11;
SB_CommandPacket = (SB_CommandPacket << 10) | (SB_BlueCommand & 1023);
SB_CommandPacket = (SB_CommandPacket << 10) | (SB_RedCommand & 1023);
SB_CommandPacket = (SB_CommandPacket << 10) | (SB_GreenCommand & 1023);shiftOut(datapin, clockpin, MSBFIRST, SB_CommandPacket >> 24);
shiftOut(datapin, clockpin, MSBFIRST, SB_CommandPacket >> 16);
shiftOut(datapin, clockpin, MSBFIRST, SB_CommandPacket >> 8);
shiftOut(datapin, clockpin, MSBFIRST, SB_CommandPacket);delay(1); // adjustment may be necessary depending on chain length
digitalWrite(latchpin,HIGH); // latch data into registers
delay(1); // adjustment may be necessary depending on chain length
digitalWrite(latchpin,LOW);
}void loop() {
SB_CommandMode = B01; // Write to current control registers
SB_RedCommand = 0; // Full current
SB_GreenCommand = 0; // Full current
SB_BlueCommand = 127; // Full current
SB_SendPacket();SB_CommandMode = B00; // Write to PWM control registers
//SB_RedCommand = 0; // Maximum red
//SB_GreenCommand = 0; // Minimum green
SB_BlueCommand = fade; // Minimum blue
SB_SendPacket();if(fade < 1004){
fade = fade + 20;
}Serial.println(fade);
delay(50);
}
I am getting the blue to fade nicely from 3 - 1023, but the red and green channels flash a little every time it cycles through the loop. Any ideas what I might be doing wrong here? (I will want the red and green to not turn on at some point, just not on its own will.)
Thanks, Patrick