8x8 LED dot Matrix (1588AS) [D015]
https://www.youtube.com/watch?v=og9wftJlcR0
* Specs
ED DOT MATRIX 8X8 HS-1588AB (RED)
* Contents
- Connect
1 - R220 - D13
2 - R220 - D12
3 - R220 - D11
4 - R220 - D10
5 - R220 - A2
6 - R220 - A3
7 - R220 - A4
8 - R220 - A5
9 - D2
10 - D3
11 - D4
12 - D5
13 - D6
14 - D7
15 - D8
16 - D9
- Ref Source
http://arduino-er.blogspot.kr/2014/08/walking-bit-on-88-led-matrix-with.html
- Key Code
// 2-dimensional array of row pin numbers:
const int row[8] = {
2, 7, 19, 5, 13, 18, 12, 16
};
// 2-dimensional array of column pin numbers:
const int col[8] = {
6, 11, 10, 3, 17, 4, 8, 9
};
// 2-dimensional array of pixels:
int pixels[8][8];
int posX = 7;
int posY = 7;
int count = 30;
bool bg = false;
void setup() {
// initialize the I/O pins as outputs
// iterate over the pins:
for (int thisPin = 0; thisPin < 8; thisPin++) {
// initialize the output pins:
pinMode(col[thisPin], OUTPUT);
pinMode(row[thisPin], OUTPUT);
// take the col pins (i.e. the cathodes) high to ensure that
// the LEDS are off:
digitalWrite(col[thisPin], HIGH);
}
setupScreen();
}
void loop() {
// draw the screen:
refreshScreen();
if(count-- == 0){
count = 500;
if(posX--==0){
posX = 7;
if(posY--==0){
posY = 7;
bg = !bg;
}
}
setupScreen();
}
}
void setupScreen(){
if(bg){
//ON all others
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
pixels[x][y] = LOW;
}
}
//OFF current pos
pixels[posX][posY] = HIGH;
}else{
//OFF all others
for (int x = 0; x < 8; x++) {
for (int y = 0; y < 8; y++) {
pixels[x][y] = HIGH;
}
}
//ON current pos
pixels[posX][posY] = LOW;
}
}
void refreshScreen() {
// iterate over the rows (anodes):
for (int thisRow = 0; thisRow < 8; thisRow++) {
// take the row pin (anode) high:
digitalWrite(row[thisRow], HIGH);
// iterate over the cols (cathodes):
for (int thisCol = 0; thisCol < 8; thisCol++) {
// get the state of the current pixel;
int thisPixel = pixels[thisRow][thisCol];
// when the row is HIGH and the col is LOW,
// the LED where they meet turns on:
digitalWrite(col[thisCol], thisPixel);
// turn the pixel off:
if (thisPixel == LOW) {
digitalWrite(col[thisCol], HIGH);
}
}
// take the row pin low to turn off the whole row:
digitalWrite(row[thisRow], LOW);
}
}
'3) Actuator > LED_Dot_Matrix' 카테고리의 다른 글
MAX7219 Dot Matrix Module (MAX7219) [D057] (0) | 2016.09.21 |
---|---|
MAX7219 Dot Matrix 4 in One Module (MAX7219) [D080] (0) | 2016.09.05 |