BASIC4MCU | 질문게시판 | 아두이노 도트매트릭스 도와주세요 고수님들
페이지 정보
작성자 민이민이 작성일2018-12-13 22:09 조회8,292회 댓글4건본문
아두리노 도트매트릭스를 이용해서 움직이는 이니셜 + 숫자 조합 만들기를 찾다가 발견해서 돌렸는데
딱 제가 원하는 코드인데 해석 해주실분 계신가요 매우 급한데 부탁좀 드릴게요 고수님들...
그리고 코드를 조금 바꿔서 한글도 나올 수 있게 만들었는데 도트가 5,8 사이즈에 끊겨서 혹시 8,8 사이즈로 바꾸는 법 아시는 분 부탁좀 드리겟습니다 ♥♥♥♥♥♥♥♥
#include <MaxMatrix.h>
#include <avr/pgmspace.h>
PROGMEM const unsigned char CH[] = {
3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space
1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // !
3, 8, B00000011, B00000000, B00000011, B00000000, B00000000, // "
5, 8, B00010100, B00111110, B00010100, B00111110, B00010100, // #
4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $
5, 8, B01100011, B00010011, B00001000, B01100100, B01100011, // %
5, 8, B00110110, B01001001, B01010110, B00100000, B01010000, // &
1, 8, B00000011, B00000000, B00000000, B00000000, B00000000, // '
3, 8, B00011100, B00100010, B01000001, B00000000, B00000000, // (
3, 8, B01000001, B00100010, B00011100, B00000000, B00000000, // )
5, 8, B00101000, B00011000, B00001110, B00011000, B00101000, // *
5, 8, B00001000, B00001000, B00111110, B00001000, B00001000, // +
2, 8, B10110000, B01110000, B00000000, B00000000, B00000000, // ,
4, 8, B00001000, B00001000, B00001000, B00001000, B00000000, // -
2, 8, B01100000, B01100000, B00000000, B00000000, B00000000, // .
4, 8, B01100000, B00011000, B00000110, B00000001, B00000000, // /
4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // 0
3, 8, B01000010, B01111111, B01000000, B00000000, B00000000, // 1
4, 8, B01100010, B01010001, B01001001, B01000110, B00000000, // 2
4, 8, B00100010, B01000001, B01001001, B00110110, B00000000, // 3
4, 8, B00011000, B00010100, B00010010, B01111111, B00000000, // 4
4, 8, B00100111, B01000101, B01000101, B00111001, B00000000, // 5
4, 8, B00111110, B01001001, B01001001, B00110000, B00000000, // 6
4, 8, B01100001, B00010001, B00001001, B00000111, B00000000, // 7
4, 8, B00110110, B01001001, B01001001, B00110110, B00000000, // 8
4, 8, B00000110, B01001001, B01001001, B00111110, B00000000, // 9
2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // :
2, 8, B10000000, B01010000, B00000000, B00000000, B00000000, // ;
3, 8, B00010000, B00101000, B01000100, B00000000, B00000000, // <
3, 8, B00010100, B00010100, B00010100, B00000000, B00000000, // =
3, 8, B01000100, B00101000, B00010000, B00000000, B00000000, // >
4, 8, B00000010, B01011001, B00001001, B00000110, B00000000, // ?
5, 8, B00111110, B01001001, B01010101, B01011101, B00001110, // @
4, 8, B01111110, B00010001, B00010001, B01111110, B00000000, // A
4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B
4, 8, B00111110, B01000001, B01000001, B00100010, B00000000, // C
4, 8, B01111111, B01000001, B01000001, B00111110, B00000000, // D
4, 8, B01111111, B01001001, B01001001, B01000001, B00000000, // E
4, 8, B01111111, B00001001, B00001001, B00000001, B00000000, // F
4, 8, B00111110, B01000001, B01001001, B01111010, B00000000, // G
4, 8, B01111111, B00001000, B00001000, B01111111, B00000000, // H
3, 8, B01000001, B01111111, B01000001, B00000000, B00000000, // I
4, 8, B00110000, B01000000, B01000001, B00111111, B00000000, // J
4, 8, B01111111, B00001000, B00010100, B01100011, B00000000, // K
4, 8, B01111111, B01000000, B01000000, B01000000, B00000000, // L
5, 8, B01111111, B00000010, B00001100, B00000010, B01111111, // M
5, 8, B01111111, B00000100, B00001000, B00010000, B01111111, // N
4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // O
4, 8, B01111111, B00001001, B00001001, B00000110, B00000000, // P
4, 8, B00111110, B01000001, B01000001, B10111110, B00000000, // Q
4, 8, B01111111, B00001001, B00001001, B01110110, B00000000, // R
4, 8, B01000110, B01001001, B01001001, B00110010, B00000000, // S
5, 8, B00000001, B00000001, B01111111, B00000001, B00000001, // T
4, 8, B00111111, B01000000, B01000000, B00111111, B00000000, // U
5, 8, B00001111, B00110000, B01000000, B00110000, B00001111, // V
5, 8, B00111111, B01000000, B00111000, B01000000, B00111111, // W
5, 8, B01100011, B00010100, B00001000, B00010100, B01100011, // X
5, 8, B00000111, B00001000, B01110000, B00001000, B00000111, // Y
4, 8, B01100001, B01010001, B01001001, B01000111, B00000000, // Z
2, 8, B01111111, B01000001, B00000000, B00000000, B00000000, // [
4, 8, B00000001, B00000110, B00011000, B01100000, B00000000, // \ backslash
2, 8, B01000001, B01111111, B00000000, B00000000, B00000000, // ]
3, 8, B00000010, B00000001, B00000010, B00000000, B00000000, // hat
4, 8, B01000000, B01000000, B01000000, B01000000, B00000000, // _
2, 8, B00000001, B00000010, B00000000, B00000000, B00000000, // `
5, 8, B01001010, B10100111, B10101010, B01011111, B00000010, // a
5, 8, B00011111, B11010001, B10011111, B10000000, B10111111, // b
5, 8, B00010001, B11110001, B00010001, B11110001, B00010111, // c
5, 8, B01000100, B10100011, B10100100, B10100010, B01001111, // d
5, 8, B00000110, B01101111, B01000110, B01000000, B01001111, // e
5, 8, B00100001, B00100001, B11100001, B00100001, B00101111, // f
4, 8, B00000000, B11111111, B10000001, B10000001, B11111111, // g
4, 8, B00001000, B01111111, B00000000, B01111111, B00000000, // h
5, 8, B11111001, B10001001, B10001111, B00000000, B11111111, // i
5, 8, B10000001, B10001001, B10001001, B10111111, B10000000, // j
5, 8, B10001000, B10000100, B10000011, B10000100, B10001000, // k
4, 8, B00000000, B11111111, B10000001, B10000001, B11111111, // l
2. 8, B11111111, B00001000, B00000000, B00000000, B00000000, // m
5, 8, B10001000, B10000100, B10000011, B10000100, B10001000, // n
4, 8, B00111000, B01000100, B01000100, B00111000, B00000000, // o
4, 8, B11111100, B00100100, B00100100, B00011000, B00000000, // p
4, 8, B00011000, B00100100, B00100100, B11111100, B00000000, // q
4, 8, B01111100, B00001000, B00000100, B00000100, B00000000, // r
4, 8, B01001000, B01010100, B01010100, B00100100, B00000000, // s
3, 8, B00000100, B00111111, B01000100, B00000000, B00000000, // t
4, 8, B00111100, B01000000, B01000000, B01111100, B00000000, // u
5, 8, B00011100, B00100000, B01000000, B00100000, B00011100, // v
5, 8, B00111100, B01000000, B00111100, B01000000, B00111100, // w
5, 8, B01000100, B00101000, B00010000, B00101000, B01000100, // x
4, 8, B10011100, B10100000, B10100000, B01111100, B00000000, // y
3, 8, B01100100, B01010100, B01001100, B00000000, B00000000, // z
3, 8, B00001000, B00110110, B01000001, B00000000, B00000000, // {
1, 8, B01111111, B00000000, B00000000, B00000000, B00000000, // |
3, 8, B01000001, B00110110, B00001000, B00000000, B00000000, // }
4, 8, B00001000, B00000100, B00001000, B00000100, B00000000, // ~
};
int data = 8; // DIN pin of MAX7219 displays
int load = 9; // CS pin of MAX7219 displays
int clock = 10; // CLK pin of MAX7219 displays
int scrollSpeed = 150; // speed of scrolling text, lower is faster
int maxInUse = 5; //Number of MAX7219 displays
MaxMatrix m(data, load, clock, maxInUse); // define Library
byte buffer[10];
char inData[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; // The string (max 64 bytes)
char inChar; // Where to store the character read
byte index = 0; // Index into array; where to store the character
void setup(){
m.init(); // init display
m.setIntensity(7); // LED light intensity from 0 (dimmest) to 15
Serial.begin(9600); // init serial connection
}
void loop(){
// Get input from serial connection
index=0;
while(Serial.available() > 0) // Don't read unless there is data
{
if(index < 63) // One less than the size of the array
{
inChar = Serial.read(); // Read a character
Serial.write(inChar);
inData[index] = inChar; // Store it
index++; // Increment where to write next
inData[index] = '\0'; // Null terminate the string
}
}
byte c;
delay(100);
m.shiftLeft(false, true);
printStringWithShift(inData, scrollSpeed); // Send scrolling Text
clearLCD(maxInUse, scrollSpeed);
}
// Put extracted character on Display
void printCharWithShift(char c, int shift_speed){
if (c < 32) return;
c -= 32;
memcpy_P(buffer, CH + 7*c, 7);
m.writeSprite(maxInUse*8, 0, buffer);
m.setColumn(maxInUse*8 + buffer[0], 0);
for (int i=0; i<buffer[0]+1; i++)
{
delay(shift_speed);
m.shiftLeft(false, false);
}
}
// Extract characters from Scrolling text
void printStringWithShift(char* s, int shift_speed){
while (*s != 0){
printCharWithShift(*s, shift_speed);
s++;
}
}
// Add trailing space to clear the display
void clearLCD(int maxInUse, int shift_speed){
for (int i=0; i<maxInUse*8; i++)
{
m.setColumn((maxInUse*8), 0);
delay(shift_speed);
m.shiftLeft(false, false);
}
}
댓글 4
조회수 8,292민이민이님의 댓글
민이민이 작성일
너무 초보라 모르는게 많네요 위에꺼 넘 많은거 같아서 모르겠는건 밑에...
코드에 주석좀부탁드립니다.
m.init();
index=0;
while(Serial.available() > 0)
if(index < 63)
inChar = Serial.read();
inData[index]
index++;
byte c;
m.shiftLeft(false, false);
emcpy_P(buffer, CH + 7*c, 7);
m.writeSprite(maxInUse*8, 0, buffer);
m.setColumn(maxInUse*8 + buffer[0], 0);
if (c < 32) return;
for (int i=0; i<maxInUse*8; i++)
m.setColumn((maxInUse*8), 0);
delay(shift_speed);
void printStringWithShift(char* s, int shift_speed)
while (*s != 0){
printCharWithShift(*s, shift_speed);
s++;
master님의 댓글
master 작성일동작시켜봤나요?
민이민이님의 댓글
민이민이 작성일네 돌아갑니당
master님의 댓글
master 작성일
https://www.google.com/search?q=%EC%95%84%EB%91%90%EC%9D%B4%EB%85%B8+MAX7219&oq=%EC%95%84%EB%91%90%EC%9D%B4%EB%85%B8+MAX7219&aqs=chrome..69i57j69i61l2j69i59j0l2.3891j0j7&sourceid=chrome&ie=UTF-8
설명이 나온글을 찾아서 읽어보시고
8x8 예제를 찾아보세요