-
[ROS] 아두이노 dot matrix with MAX7219Engineer/Robotic 2017. 2. 19. 18:52
안녕하세요. 오랫만에 글을 올리는 꿈꾸는 개발자 몽키준입니다.
몇 주전에 구매했던 8x8 도트 매트릭스 모듈을 아두이노를 활용해 확인해 보려고 합니다.
MAX7219 와 함께 날라온 빨간색 LED와 추가로 구매한 White led 를 비교해 보려고 합니다.
1. 구매정보
https://www.aliexpress.com/item/Smart-Electronics-MAX7219-Dot-Matrix-Microcontroller-MCU-LED-Display-Control-Module-Finished-Goods-for-arduino-Diy/32315049387.html?
2. LED control library of arduino
http://playground.arduino.cc/Main/LedControlDemos
3. 영상
4. 코드
//We always have to include the library #include "LedControl.h" /* Now we need a LedControl to work with. ***** These pin numbers will probably not work with your hardware ***** pin 12 is connected to the DataIn pin 11 is connected to the CLK pin 10 is connected to LOAD We have only a single MAX72XX. */ LedControl lc=LedControl(12,11,10,1); /* we always wait a bit between updates of the display */ unsigned long delaytime=1000; void setup() { /* The MAX72XX is in power-saving mode on startup, we have to do a wakeup call */ lc.shutdown(0,false); /* Set the brightness to a medium values */ lc.setIntensity(0,5); /* and clear the display */ lc.clearDisplay(0); } /* This method will display the characters for the word "Arduino" one after the other on the matrix. (you need at least 5x7 leds to see the whole chars) */ void writeArduinoOnMatrix() { /* here is the data for the characters */ byte a[5]={B01111110,B10001000,B10001000,B10001000,B01111110}; byte r[5]={B00111110,B00010000,B00100000,B00100000,B00010000}; byte d[5]={B00011100,B00100010,B00100010,B00010010,B11111110}; byte u[5]={B00111100,B00000010,B00000010,B00000100,B00111110}; byte i[5]={B00000000,B00100010,B10111110,B00000010,B00000000}; byte n[5]={B00111110,B00010000,B00100000,B00100000,B00011110}; byte o[5]={B00011100,B00100010,B00100010,B00100010,B00011100}; byte arr[][8] = { #if 0 { // kim B11111001, B00001001, B00001001, B00000000, B11111111, B10000001, B10000001, B11111111, }, { // su B00010000, B00101000, B01000100, B00000000, B11111111, B00010000, B00010000, B00010000, }, { // ji B11111101, B00100001, B00100001, B01010001, B10001001, B10001001, B10001001, B10001001, }, { // sa B00100010, B00100010, B01010010, B01010010, B01010011, B01010010, B10001010, B10001010, }, { // lang B11110010, B00010010, B11110010, B10000011, B11110010, B00000000, B01111110, B01111110, }, { // hae B00100101, B11110101, B00000101, B01100101, B10010111, B10010101, B10010101, B01100101, }, #endif { // heart B00000000, B01100110, B11111111, B11111111, B01111110, B00111100, B00011000, B00000000, }, { // eyes B00000000, B00111100, B01111110, B01100110, B01100110, B01111110, B00111100, B00000000, }, { // eyes-1 B00111100, B01111110, B11111111, B11111001, B11111001, B11111111, B01111110, B00111100, }, { // eyes-2 B00111100, B01111110, B11111111, B10011111, B10011111, B11111111, B01111110, B00111100, }, { // eyes B01110000, B10001000, B10000100, B10001010, B10001101, B01000010, B01111100, B00000000, }, { // tt B00000000, B00000000, B11111111, B00100100, B00100100, B00100100, B00000000, B00000000, }, { // smile B00000000, B00000000, B01111110, B11000011, B11000011, B00000000, B00000000, B00000000, }, }; /* now display them one by one with a small delay */ for (int i = 0; i < sizeof(arr)/sizeof(arr[0]); i++) { lc.setRow(0,0,arr[i][0]); lc.setRow(0,1,arr[i][1]); lc.setRow(0,2,arr[i][2]); lc.setRow(0,3,arr[i][3]); lc.setRow(0,4,arr[i][4]); lc.setRow(0,5,arr[i][5]); lc.setRow(0,6,arr[i][6]); lc.setRow(0,7,arr[i][7]); delay(delaytime); } } /* This function lights up a some Leds in a row. The pattern will be repeated on every row. The pattern will blink along with the row-number. row number 4 (index==3) will blink 4 times etc. */ void rows() { for(int row = 0; row < 8 ; row++) { delay(delaytime); lc.setRow(0, row, B10100000); delay(delaytime); lc.setRow(0, row, (byte)0); for(int i=0 ; i < row; i++) { delay(delaytime); lc.setRow(0, row, B10100000); delay(delaytime); lc.setRow(0,row,(byte)0); } } } /* This function lights up a some Leds in a column. The pattern will be repeated on every column. The pattern will blink along with the column-number. column number 4 (index==3) will blink 4 times etc. */ void columns() { for(int col = 0 ; col < 8 ; col++) { delay(delaytime); lc.setColumn(0, col, B10100000); delay(delaytime); lc.setColumn(0, col, (byte)0); for(int i = 0 ; i < col; i++) { delay(delaytime); lc.setColumn(0, col, B10100000); delay(delaytime); lc.setColumn(0, col, (byte)0); } } } /* This function will light up every Led on the matrix. The led will blink along with the row-number. row number 4 (index==3) will blink 4 times etc. */ void single() { for(int row=0; row < 8; row++) { for(int col=0 ; col<8 ; col++) { delay(delaytime); lc.setLed(0,row,col,true); delay(delaytime); for(int i=0 ; i < col ; i++) { lc.setLed(0,row,col,false); delay(delaytime); lc.setLed(0,row,col,true); delay(delaytime); } } } } void loop() { writeArduinoOnMatrix(); // rows(); // columns(); // single(); }
'Engineer > Robotic' 카테고리의 다른 글
[OPENCV] edge 검출하기 (0) 2017.05.24 [ROS] rosserial 사용하기 (0) 2017.05.24 [ROS] Asulada Ver. 1 (0) 2016.09.29 [ROS] install roscore (0) 2016.09.22 [ROS] run node with gdb (0) 2016.08.23