hey guys,
I am new to this site (and relatively new to arduino, I have only used a basic stamp before :o )
anyway, I currently have a ardunio duemilanove 328 hooked up to a tri-colour LED 8x8 matrix via 3 CMOS 4514 (one per LED colour) and one CMOS 4515 (for common ground) (most of this is irrelevant, just a bit of background, but stay with me!)
I have written some code which should hopefully light each (blue) LED one after the other, stating from the first led and moving up to the 64th.
I have created a FOR loop which should count from 0 to 63, inside which each bit of the variable n is masked off and then a pin output is writen to the latch (BCD value between 0 - 63, after which the FOR loop should reset).
but nothing happens when I upload it, void blue, void red and void latch are all tested as working.
pins are connected as follows
3 latch
5 red led enable
6 blue led enable
(the latch latches the output from the data pins, into a BCD decoder, one decoder is used per LED colour, when the enable goes LOW, the decoder is allowed to output onto the LED matrix).
pins:
8 data 0
9 -
10 -
11 -
12 -
13 data 5
int b0 = B0;
int b1 = B0;
int b2 = B0;
int b3 = B0;
int b4 = B0;
int b5 = B0;
void setup(){
pinMode(3,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9, INPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);
digitalWrite(3,LOW);
digitalWrite(5, HIGH);
digitalWrite(6,HIGH);
}
void latch (){
digitalWrite(3, HIGH);
delay(2);
digitalWrite(3, LOW);
}
//red is on pin 5
void red () {
digitalWrite(5,LOW);
delay(1);
digitalWrite(5, HIGH);
}
//blue is on pin 6
void blue (){
digitalWrite(6,LOW);
delay(2);
digitalWrite(6, HIGH);
}
//all code up to this point works on other sektches
void loop(){
for(int n = B0; n == B111111; n + B1){
//mask each bit of n to create 6 bit output
b0 = n & B000001;
if(b0 == B1) {
digitalWrite(8, HIGH);
}
else{
digitalWrite(8, LOW);
}
b1 = n & B000010;
if(b1 == B1) {
digitalWrite(9, HIGH);
}
else{
digitalWrite(9, LOW);
}
b2 = n & B000100;
if(b2 == B1) {
digitalWrite(10, HIGH);
}
else{
digitalWrite(10, LOW);
}
b3 = n & B001000;
if(b3 == B1) {
digitalWrite(11, HIGH);
}
else{
digitalWrite(11, LOW);
}
b4 = n & B010000;
if(b4 == B1) {
digitalWrite(12, HIGH);
}
else{
digitalWrite(12, LOW);
}
b5 == n & B100000;
if(b5 == B1) {
digitalWrite(13, HIGH);
}
else{
digitalWrite(13, LOW);
}
latch();
blue();
}
}
any ideas why this fails to work?