Hi. I created a custom RGB led array. I am simulating common anode RGB leds like on the attachment image. Because Tinkercad doesn't have common anode RGB leds. I am opening and closing leds with octocouplers fastly and changing PWM pins for led colors. I tried it in real life and it works. I can define colors for the leds one by one and leds working in correct color. I need help for integrating this system to FastLED project. If it is too hard, how can I animate this leds. Thanks for help and Sorry for my bad English. The code and image are on the attachment.
My code:
int leds[4] = {13,12,11,10};
int red = 6;
int green = 5;
int blue = 3;
int _delay = 5;
void setup()
{
pinMode(leds[0], OUTPUT);
pinMode(leds[1], OUTPUT);
pinMode(leds[2], OUTPUT);
pinMode(leds[3], OUTPUT);
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);
}
void loop()
{
delay(_delay);
CloseLed();
SetColor(255,0,0);
OpenLed(0);
delay(_delay);
CloseLed();
SetColor(0,255,0);
OpenLed(1);
delay(_delay);
CloseLed();
SetColor(0,0,255);
OpenLed(2);
delay(_delay);
CloseLed();
SetColor(0,255,120);
OpenLed(3);
}
void OpenLed(int led){
for(int i=0;i<4;i++){
if(led==i){
digitalWrite(leds[i], HIGH);
}else{
digitalWrite(leds[i], LOW);
}
}
}
void CloseLed(){
for(int i=0;i<4;i++){
digitalWrite(leds[i], LOW);
}
}
void SetColor(int r, int g, int b){
analogWrite(red, r);
analogWrite(green, g);
analogWrite(blue, b);
}