Electgpl

PIC - Matrix 8x32 74595

Dec 18th, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.69 KB | None | 0 0
  1. #include <16F628A.h>
  2. #FUSES NOWDT, HS, NOPUT, MCLR
  3. #use delay(clock=20000000)
  4. #define LARGO  56
  5. #define DATA   PIN_A0
  6. #define CLOCK  PIN_A1
  7. #define LATCH  PIN_A2
  8. void f74595_init(){
  9.    output_bit(DATA,1);
  10.    output_bit(CLOCK,1);
  11.    output_bit(DATA,0);
  12. }
  13. void f74595_clock(){
  14.    output_bit(CLOCK,1);
  15.    output_bit(CLOCK,0);
  16.    output_bit(LATCH,1);
  17.    output_bit(LATCH,0);
  18. }
  19. int const tabla[LARGO+64]={
  20. 0,0,0,0,0,0,0,0,  //8 espacios
  21. 0,0,0,0,0,0,0,0,  //8 espacios
  22. 0,0,0,0,0,0,0,0,  //8 espacios
  23. 0,0,0,0,0,0,0,0,  //8 espacios
  24. 255,137,129,0,    //Letra E
  25. 255,128,128,0,    //Letra L
  26. 255,137,129,0,    //Letra E
  27. 126,129,129,0,    //Letra C
  28. 1,255,1,0,        //Letra T
  29. 126,129,241,0,    //Letra G
  30. 254,17,14,0,      //Letra P
  31. 255,128,128,0,    //Letra L
  32. 0,0,              //2 espacios
  33. 255,6,255,0,      //Letra M
  34. 254,17,254,0      //Letra A
  35. 1,255,1,0,        //Letra T
  36. 255,25,230,0,     //Letra R
  37. 255,0,            //Letra I
  38. 231,24,231,0,     //Letra X
  39. 0,0,0,0,0,0,0,0,  //8 espacios
  40. 0,0,0,0,0,0,0,0,  //8 espacios
  41. 0,0,0,0,0,0,0,0,  //8 espacios
  42. 0,0,0,0,0,0,0,0   //8 espacios
  43. };
  44. void main(){
  45.    int i,j,k;                          //Variables contadores
  46.    while(TRUE){                        //Ciclo infinito
  47.       for(i=0;i<LARGO+32;i++){         //Recorrido de tabla
  48.          for(k=0;k<24;k++){            //Refresco de matriz
  49.             f74595_init();             //Inicializa 74595
  50.             for(j=0;j<32;j++){         //Barrido de Columnas
  51.                f74595_clock();         //desplaza las columnas
  52.                output_b(~tabla[j+i]);  //Desplazamiento de tabla
  53.                delay_us(20);           //Demora de multiplexado
  54.             }
  55.          }
  56.       }
  57.    }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment