miércoles, 11 de noviembre de 2015

Laboratorio # 10

Descripción :

En este laboratorio el objetivo sera  controlar con el arduino una matiz LED 8x8 a través de un integrado IC MAX7219 , para mostrar un numero de 0 a 9, dependiendo de la posición del potenciometro.

Materiales:


  • Computador con el respectivo software de arduino 
  • Arduino con su respectivo cable USB
  • Matriz LEDs 8x8
  • Protoboard
  • Potenciometro 10k
  • Cables

Diagramas:

Montaje


Esquemático



PCB





Código



  1. // Laboratorio #10
  2. // Programa Arduino
  3. // Control de una matriz de LEDs 8x8 para mostrar un numero de 0 a 9
  4. // Johnson Camilo Barona Sanchez
  5. // Programacion de sistemas embebidos
  6. // Universidad Santiago de Cali
  7. // inicio de código
  8. #include "LedControl.h"
  9. #define Pot A0
  10. int DIN = 12;
  11. int CS =  10;
  12. int CLK = 11;
  13. byte cero[8]= {0x3C,0x7E,0x66,0x66,0x66,0x66,0x7E,0x3C,};
  14. byte numeros [10][8]= {{0x3C,0x7E,0x66,0x66,0x66,0x66,0x7E,0x3C,}, //0
  15.                       {0x38,0x38,0x18,0x18,0x18,0x18,0x3C,0x3C},  //1
  16.                       {0x1E,0x3F,0x77,0x66,0x0E,0x1C,0x3F,0x3F}, //2
  17.                       {0x7C,0x7C,0x0C,0x3C,0x3C,0x0C,0x7C,0x7C}, //3
  18.                       {0x1E,0x3E,0x76,0xE6,0xFF,0x7F,0x06,0x06},//4
  19.                       {0x3F,0x3F,0x30,0x3E,0x3F,0x03,0x3F,0x3E}, //5
  20.                       {0x3F,0x3F,0x30,0x3F,0x3F,0x33,0x3F,0x3F}, //6
  21.                       {0x3E,0x7E,0x66,0x06,0x06,0x06,0x06,0x06}, //7
  22.                       {0x3C,0x7E,0x66,0x66,0x7E,0x66,0x66,0x3C}, //8
  23.                       {0x3C,0x7E,0x66,0x66,0x7E,0x06,0x7E,0x3C}};//9
  24. int pinPot = A0;    // Entrada para el potenciómetro.
  25. int valorPot = 0;   // variable para el valor del sensor.
  26. int pos = map (valorPot, 0, 1023, 0, 10);
  27. #define NBR_MTX 2
  28. LedControl lc=LedControl(12,11,10, NBR_MTX);
  29. String digits= "1234567890";
  30. int digitCounter=0;
  31. void setup() {
  32.   /*
  33.    The MAX72XX is in power-saving mode on startup,
  34.    we have to do a wakeup call
  35.    */
  36.    pinMode(pinPot, INPUT);
  37.   Serial.begin (9600);
  38.   Serial.println("Setup");
  39.   digitCounter=0;
  40.   for (int i=0; i< NBR_MTX; i++){
  41.     lc.shutdown(i,false);
  42.   /* Set the brightness to a medium values */
  43.     lc.setIntensity(i,1);
  44.   /* and clear the display */
  45.     lc.clearDisplay(i);
  46.   }
  47. }
  48. void loop() {
  49.   // put your main code here, to run repeatedly:
  50. int Pos = analogRead(pinPot);
  51. Pos = map (Pos, 0, 1023, 0,10);
  52.   writeLetra(numeros[Pos]);
  53. Serial.println(pos);
  54. }
  55. void writeLetra (byte a[]){
  56.   for (int i = 0; i<8; i++){
  57.       lc.setRow(0,i,a[i]);
  58.   }
  59.   delay(200);
  60.   for (int i = 0; i<8; i++){
  61.       lc.setRow(0,i,0);
  62.   }
  63. }


Proceso de montaje





Vídeo 








No hay comentarios:

Publicar un comentario