Ok, so I just got my Arduino today. Been playing with it and programming LED's to do different things. But I have come across a weirdness I can't understand.
ok, I have a 2x2 led matrix, and I am trying to turn on just the bottom right light.
ok, so you will see some code in there for something else I was about to do, but I can't get past this.
xx or x0
x0 xx
that is what I am trying to achieve by turning the row1 and column1 polarities to make the LED come on. So basically if I am trying to use the second column, things get weird and I get this.
00 or xx
xx 00
I have checked connections a bunch of times, in fact, I can get them all to light up one at a time using another method, so I know my lights are wired correctly.
If someone could point me in the direction of my lost logic, I would greatly appreciate it.
Also, using atmega board,
// put your setup code here, to run once:
int row[] = {8,9};
int col[] = {11,12};
int columns = 2;
int rows = 2;
byte DATA[] = {0,0};
int pause = 1;
void setup()
{
for (int i=0;i<2;i++)
{
pinMode(row[i],OUTPUT);
pinMode(col[i],OUTPUT);
}
allOff();
}
void loop() {
// put your main code here, to run repeatedly:
//DATA[0] = B00000010;
//DATA[1] = B00000001;
//showPattern();
digitalWrite(row[1],HIGH);
digitalWrite(col[1],LOW);
}
void showPattern(){
for (int thisrow=0;thisrow<rows;thisrow++)
{
allOff();
digitalWrite(row[thisrow],HIGH);
for (int thiscol=0;thiscol<columns;thiscol++)
{
if (bitRead(DATA[thisrow],columns-thiscol-1)==1)
{
digitalWrite(col[thiscol],LOW);
}
else
{
digitalWrite(col[thiscol],HIGH);
}
}
delay(pause);
}
}
void allOff(){
for (int i=1;i<2;i++)
{
digitalWrite(row[i],LOW);
digitalWrite(col[i],HIGH);
}
}