Step 6A test sketch
- Copyright (c) 2009 qs@quantsuff.com
- Scanning horizontal and vertical pixels
- LED Matrix row:1-5; col:1-6
- Map PORTB == D8:D12 pin[row+7] : +v
- PORTD == D2:D7 pin[8-col] ; Gnd
- Our output: col::D2:D7 -ve (LOW) while row::D8:D13 +ve
int delayTime= 80; // 1mS increments before next LED
// change from 1-100 and see what happens
int delayStep;
int ledPin, col, row ;
void setup() // run once, when the sketch starts
{
for (ledPin=2; ledPin<=12; ledPin++) // Standard setup for LMP
{ pinMode(ledPin, OUTPUT); // sets the digital pin as output
digitalWrite(ledPin,(ledPin<=7)) ; // and sets all OFF
}
}
void loop() // run over and over again
/* Map PORTB == D8:D13
- PORTD == D0:D7
- Our output: col::D7:D2
- (8-col) -ve (LOW)
- while row::D8:D13 +ve
- (row+7) +ve (HIGH)
{
for (row=1; row<=5; row++) { // Vertical: left to right
digitalWrite(row+7,HIGH); // Enable entire ROW
for (col=1; col<=6; col++) { // then one pixel per col
digitalWrite(8-col,LOW); // gets turned on
delay(delayTime); // for a moment
digitalWrite(8-col,HIGH); // then OFF
} // before next one
digitalWrite(row+7, LOW); // We're done with this row
}
for (col=6; col>=1; col--) { // Going UP right to left
digitalWrite(8-col,LOW); // A shortcut: leave col enabled
for (row=5; row>=1; row--) {
digitalWrite(row+7,HIGH); // Turn 1 pixel on
delay(delayTime); // Wait a moment
digitalWrite(row+7,LOW); // then off...
}
digitalWrite(8-col,HIGH); // finished with this column
}
}
| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|











































