Este laboratorio consiste en mostrar un mensaje a través de una matriz de LEDs 8x8 ,en donde esta matriz recibirá los datos en modo serial por parte de un IC MAX7219 que controlara la visualización del byte enviado. Utilizamos la librería "LedControl.h", la cual es una librería de arduino para controlar el integrado, por medio de esta enviamos los comandos al IC y en el momento poderlos ver en la matriz.
Materiales :
- Computador con el respectivo software de arduino y processing
- Arduino con su respectivo cable USB
- Protoboard
- Matriz LEDs 8x8 entrada serial desde Interface Max7219
- Cables
Diagramas :
Montaje
Esquemático
Código
Arduino
- // Laboratorio #11
- // Programa Arduino
- // Controlar una Matriz de leds 8x8 desde una interfaz en Processing
- // Johnson Camilo Barona Sanchez
- // Programacion de sistemas embebidos
- // Universidad Santiago de Cali
- // inicio de código
- //incluimos la libreria
- #include "LedControl.h"
- String texto="";
- /*
- 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=40;
- void setup() {
- Serial.begin(9600);
- /*
- 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,8);
- /* and clear the display */
- lc.clearDisplay(0);
- }
- char abcMAY[36]={'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y','Z','1','2', '3', '4', '5', '6', '7', '8', '9', '0'};
- char abcMIN[36]={'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y','z','1','2', '3', '4', '5', '6', '7', '8', '9', '0'};
- byte letras[36][5]= {
- {B11111110,B00010001,B00010001,B00010001,B11111110},//A
- {0xFF, 0x89, 0x89, 0x89, 0x76},//B
- {B01111110,B10000001,B10000001,B10000001,B01000110},//C
- {0xff, 0x81, 0x81, 0x81, 0x7e},//D
- {0x7e, 0x89, 0x89, 0x89, 0x89},//E
- {0xff, 0x09, 0x09, 0x09, 0x01},//F
- {0x7e, 0x89, 0x89, 0x89, 0xf2},//G
- {0xFF, 0x18, 0x18, 0x18,0xff},//H
- {B00000000,B10000100,B11111101,B10000000,B00000000},//I
- {0x71, 0x81, 0x7f, 0x01, 0x01},//J
- {0xff, 0x10, 0x2c, 0x42, 0x81},//K
- {0x7f, 0xc0, 0x80,0x80, 0x80},//L
- {0xff, 0x06, 0x0c, 0x06, 0xff},//M
- {B11111111,B00000100,B00001000,B00010000,B11111111}, //N
- {B01111110,B10000001,B10000001,B10000001,B01111110},//O
- {0xff, 0x09, 0x09, 0x09, 0x06},//P
- {0xbe, 0x41,0xA1, 0x81, 0x7e},//Q
- {B11111111,B00010001,B00110001,B01010001,B10001110},//R
- {0x86, 0x89, 0x89, 0x89, 0x71},//S
- {0x01, 0x01, 0xff, 0x01, 0x01},//T
- {B01111111,B11000000,B11000000,B11000000,B01111111},//U
- {0x3f, 0x40, 0x80, 0x40, 0x3f},//V
- {0x7f, 0x80, 0x70, 0x80, 0x7f},//W
- {0xe3, 0x14, 0x08, 0x14, 0xe3},//X
- {0x03, 0x04, 0xf8, 0x04, 0x03},//Y
- {0xe1, 0x91, 0x89, 0x85, 0x83 }//Z
- ,{0x00, 0x82, 0xff, 0x80,0x00},//1
- {0xc2, 0xa1, 0x91, 0x89, 0x86},//2
- {0x81,0x81,0x85,0x8b,0x71},//3
- {0x18,0x14, 0x12, 0xff, 0x00},//4
- {0x8f, 0x89, 0x89, 0x89, 0x71},//5
- {0x7c, 0x8a, 0x89, 0x89, 0x70},//6
- {0x01, 0xf1, 0x09,0x05, 0x03},//7
- {0x76, 0x89, 0x89, 0x89, 0x76},//8
- {0x06, 0x89, 0x89, 0x89, 0x7e },//9
- {B01111110,B11100001,B10011001,B10000111,B01111110},//O
- };
- /*
- 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(String mensajea) {
- /* here is the data for the characters */
- for(int j=0;j<mensajea.length();j++){
- for(int k=0;k<36;k++){
- if(mensajea.charAt(j)==abcMAY[k] || mensajea.charAt(j)==abcMIN[k]){
- palabras(letras[k]);
- }
- }
- }
- }
- void palabras(byte listd[]){
- for(int j=7;j>-4;j--){
- for(int i=4; i> -1; i--){
- lc.setRow(0,j+i,listd[i]);
- }
- delay(delaytime);
- for(int o=0; o<8 ; o++){
- lc.setRow(0,o,0);
- }
- }
- }
- void loop() {
- writeArduinoOnMatrix(texto);
- }
- void serialEvent(){
- while(Serial.available()){
- texto= Serial.readString();
- }
- }
Processing
- // Laboratorio #11
- // Programa Arduino
- // Controlar una Matriz de leds 8x8 desde una interfaz en Processing
- // Johnson Camilo Barona Sanchez
- // Programacion de sistemas embebidos
- // Universidad Santiago de Cali
- // inicio de código
- //se carga la libreria ControlP5
- import controlP5.*;
- //se carga la libreria Serial
- import processing.serial.*;
- // definir la variable cp5 del tipo ControlP5
- ControlP5 cp5;
- // definir la variable puerto del tipo Serial
- Serial puerto;
- // definir la variable text del tipo Textfield
- Textfield text;
- void setup(){
- //tamaño de la ventana
- size(500,360);
- cp5 = new ControlP5(this);
- text = cp5.addTextfield("Texto")
- .setPosition(30,50)
- .setSize(300,50)
- .setFont(createFont("Arial",30))
- .setAutoClear(false);
- cp5.addButton("Mostrar")
- .setValue(1)
- .setPosition(60,130)
- .setSize(40,30)
- .setId(2);
- String COM = Serial.list()[0];
- //comunicacion serial a 9600bps
- puerto = new Serial(this, COM, 9600);
- }
- void draw(){
- background(#000000);
- }
- void controlEvent(ControlEvent theEvent){
- if(theEvent.isAssignableFrom(Button.class)){
- for(int i = 0; i < text.getText().length(); i++){
- char dato = text.getText().charAt(i);
- puerto.write(dato);
- }
- }
- }
Proceso de montaje
Vídeo
No hay comentarios:
Publicar un comentario