Go Down

Topic: Help: Row Scanning Multiplexing RGB Led (Read 31 times) previous topic - next topic

jaspal23

Oct 12, 2018, 01:56 pm Last Edit: Oct 12, 2018, 01:57 pm by jaspal23
Hi,

I am trying to make a some patterns which run on 6 RGB Leds (Common Anode). I uploaded the circuit diagram. I have also written code but it is not a worth it. I need help on creating some patterns like 6 Leds get on with red colour then change into green and finally blue color with some interval.  

please guide me, how to make code efficient and optimized.

In diagram 4 transistors are used but now i am using 3 transistors (only 6 Leds)

Code: [Select]



const int row[4] = {12,8,7};   // Arduino row pins
const int column[6] = {11,10,9,6,5,3};   // Arduino column pins


void setup()
{
for (int i = 0;i<3; i++)
  {
    pinMode(row[i], OUTPUT);
    digitalWrite(row[i],HIGH);
  }  
for (int j = 0;j<6; j++)
  {
    pinMode(column[j], OUTPUT);
    digitalWrite(column[j], HIGH);
  }
}
void loop() {
  
analogWrite(11,255);
analogWrite(10,0);
analogWrite(9,255);

digitalWrite(12,LOW);
digitalWrite(12,HIGH);

digitalWrite(8,LOW);
digitalWrite(8,HIGH);
digitalWrite(7,LOW);
digitalWrite(7,HIGH);
}





Thanks is advance.

groundFungus

#1
Oct 12, 2018, 02:54 pm Last Edit: Oct 12, 2018, 02:55 pm by groundFungus
Code: [Select]
digitalWrite(12,LOW);
digitalWrite(12,HIGH);

digitalWrite(8,LOW);
digitalWrite(8,HIGH);
digitalWrite(7,LOW);
digitalWrite(7,HIGH);

That section of code executes so fast that it will look like nothing is happening.  Insert delay()s between the digitalWrite highs and digitalWrite lows.

Better yet learn to use millis() (and micros()) for timing.  A beginner's guide to millis().

Go Up