Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* **********************************************************************
- ** Matriz de LED de 64 pixels **.
- ** Autor: El Guajirigallo**
- ** https://youtu.be/3geIbQzH6Xc **
- */
- # include <16F877A.h>
- # use Delay(clock=4000000)
- # use Fast_io(b)
- # use Fast_io(c)
- # use fast_io(d)
- # fuses XT,NOWDT
- # byte PoRt_a = 0x05
- # byte PoRt_B = 0x06
- # byte PoRt_c = 0x07
- # byte PoRt_d = 0x08
- //# int_ext
- void Stop(){
- int j,x,y,z;
- char *w;
- long r,s=0;
- int a;
- int b=0;
- char LeTra[]= {
- 0x00,0x00,0x00,0x00,0x00,0x00,//espacio
- 0x72,0xf9,0x89,0x89,0x8f,0x46,//S
- 0x01,0x01,0xff,0xff,0x01,0x01,//T
- 0x3c,0x7e,0x81,0x81,0x7e,0x3c,//O
- 0x0e,0x11,0x91,0xff,0xff,0x81,//P
- 0x00,0x00,0x00,0x00,0x00,0x00,//espacio
- };
- do{
- a=0;
- r=0;
- w=&LeTra[b];
- for(j=0;j<6;j++){ // MUETRA LAS 6 LETRAS
- s=0b0100000000000000; //EMPIEZO EN EL BIT MAS SIGNIFICATIVO Y FUERA DE LA MATRIZ.
- for(x=0;x<5;x++){ // DESPLAZO S A LA DERECHA 2 POSICIONES 5 VECES PARA LOGRAR EL ARRAY
- r=s;
- for(y=0;y<=15;y++){ //AQUI REPITO LA LETRA 15 VECES PARA QUE SEA VISIBLE.
- for(z=0;z<6;z++){ // EN ESTE FOR FORMO LA LETRA QUE SE VA A MOSTRAR
- PoRt_c=r;
- PoRt_D= *(w+b); //MUESTRO DE SEIS BYTES AND SEIS BYTE POR EL PUERTO_D(LETRAS)
- DeLay_ms(1);
- b++;
- r=r>>1;
- } // FIN DEL FOR QUE FORMA LAS LETRAS
- r=s;
- b=0;
- }
- s=s>>2;
- //e++;
- }
- a=a+6; //INCREMENTO A DE SEIS EN SEIS QUE ES EL ANCHO DE LAS LETRAS.
- w=&LeTra[a]; //ME MUEVO EN EL ARRAY CADA SEIS POCICIONES PARA RECORRER TODAS LAS LETRAS.
- }
- }while(!input(pin_a0) || (!input(pin_a1)));
- }
- //End_Rb0_Interrupt------------------------------------------------------------
- int R_arrow[]={ 0x08,0x14,0x22,0x49,0x08,0x08,0x08,0x08} ;//RIGHT ARROW
- int l_arrow[]={ 0x08,0x08,0x08,0x08,0x49,0x22,0x14,0x08} ;//LEFT ARROW
- int Clear_Dir[8]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};// _limpiar_Direccion
- int direction[8];//ARREGLO DE 8 BYTE PARA USARLO COMO DIREECION EN QUE SE MUEVE LA FLECHA.
- long v;
- //----------------------------------------------------------------------------
- void arrow_right(void);//FUNTION QUE MUUEVE LA FLECHA ALA DERECHA
- void arrow_left(void);//FUNTION QUE MUEVE LA FLECHA ALA ISQUIERDA
- void Adv(void); //FUNTION QUE MUSTRA LOS ANUNCIOS
- void strobe(void);
- //main------------------------------------------------------------------------
- void main(){
- //EnaBle_InteRRupts(global);
- //EnaBle_InteRRupts(int_ext);
- //ext_int_edge(h_to_l);
- set_tris_a(0x0f);
- set_tris_b(0x00);
- set_tris_c(0x00);
- set_tris_d(0x00);
- //strobe();
- WHILE(1){
- Adv();
- do{
- if(!input(pin_a0)&& (!input(pin_a1))){
- Stop();
- }else
- if(!input(pin_a0)&& input(pin_a1))
- {
- strcpy(direction,Clear_Dir);
- strcpy(direction,R_arrow);
- v=0b0000000010000000;
- arrow_right();
- }
- if(!input(pin_a0)&& (!input(pin_a1)))
- {
- Stop();
- }else
- if(!input(pin_a1))//&& input(pin_a0))
- {
- strcpy(direction,Clear_Dir);
- StRcpy(direction,l_arrow);
- v=0b0000000100000000;
- arrow_left();
- }
- }While((!input(pin_a0))||(!input(pin_a1)));
- }
- }
- //Funtions----------------------------------------------------------------------
- void arrow_right(){
- int t,*p,R,h,i=0;
- long c=0;
- p=&direction[i];
- for(h=0;h<15;h++){
- c=v;
- for(R=0;R<=8;R++){
- for(t=0;t<8;t++){
- PorT_C=c;
- PorT_D= *(p+i);
- deLay_ms(1);
- i++;
- c>>=1;
- }
- c=v;
- i=0;
- }
- v=v<<1;
- }
- port_d=0x00;
- deLay_ms(50);
- }
- //arrow_left-------------------------------------------------------------------
- void arrow_left(){
- int t,*p,R,h,i=0;
- long c=0;
- p=&direction[i];
- for(h=0;h<15;h++){
- c=v;
- for(R=0;R<=8;R++){
- for(t=0;t<8;t++){
- port_c=c;
- PORT_D= *(p+i);
- deLay_ms(1);
- i++;
- c>>=1;
- }
- c=v;
- i=0;
- }
- v=v>>1;
- }
- port_d=0x00;
- deLay_ms(50);
- }
- ///////////////////////////////////////////////////////////////////////
- void Adv(){
- if((!input(pin_a0))||(!input(pin_a1))){goto salir ;} //
- deLay_ms(10);
- if((!input(pin_a0))||(!input(pin_a1))){goto salir ;}
- deLay_ms(10);
- if(!input(pin_a3)){strobe();}
- int const tabla[]={
- /*
- aqui dentro van los caracteres que la matriz va a mostrar
- ejemplo:
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0xfc,0xfe,0x12,0x12,0x12,0xfc,0x00, //A
- 0x6c,0xfe,0x92,0xaa,0x44,0xa0,0x10,0x00, //&
- 0xfc,0xfe,0x12,0x12,0x12,0xfc,0x00, //A
- 0x00,0x00,0x00,
- 0xfe,0xfe,0x92,0x92,0x82,0x00, //E
- 0xfe,0xfe,0x80,0x80,0x80,0x00, //L
- 0x78,0xfc,0x94,0x94,0x9c,0x98,0x00, //e
- 0x78,0xfc,0x84,0x84,0x48,0x00, //c
- 0x04,0x7e,0xfe,0x84,0x40,0x00, //t
- 0xf8,0xfc,0x04,0x04,0x08,0x00, //r
- 0xf6,0xf6,0x00,0x00, //i
- 0x78,0xfc,0x84,0x84,0x48,0x00, //c
- 0x60,0xf4,0x94,0xfc,0xf8,0x80,0x00, //a
- 0xfe,0xfe,0x80,0x80,0x00,// l
- 0x00,0x00,0x00,0x00,
- 0x86,0x8f,0x89,0x89,0xf9,0x71,0x00, //S
- 0x78,0xfc,0x84,0xfc,0x78,0x00, //o
- 0xfe,0xfe,0x80,0x80,0x00, //l
- 0x7c,0xfc,0x80,0x80,0x7c,0x00, //u
- 0x04,0x7e,0xfe,0x84,0x40,0x00, //t
- 0xf6,0xf6,0x00,0x00, //i
- 0x78,0xfc,0x84,0xfc,0x78,0x00, //o
- 0xfc,0xfc,0x0c,0x04,0xfc,0xf8,0x00, //n
- 0x88,0x9c,0x94,0x94,0xf4,0x64,0x00, //s
- */
- };
- if((!input(pin_a0))||(!input(pin_a1))){goto salir ;}
- int h;
- long t, r;
- const byte ColuMn[8]={1,2,4,8,16,32,64,128};
- while(1){
- for(R=0;R<995;R++){
- for(h=0;h<10;h++){
- for(t=0;t<8;t++){
- port_c=(ColuMn[t]);
- port_D=(tabla[t+r]);
- deLay_ms(1);
- }
- if((!input(pin_a0))||(!input(pin_a1))){goto salir ;}
- if(!input(pin_a3)){strobe();}
- }
- }
- if((!input(pin_a0))||(!input(pin_a1))){goto salir ;}
- if(!input(pin_a3)){strobe();}
- }
- port_c=3;
- port_d=0x18;
- delay_ms(20);
- port_d=0x00;;
- delay_ms(50);
- salir:
- deLay_ms(1);
- }
- //strobe------------------------------------------------------------------------
- void strobe(){
- int i,j,x;
- long k=0b0000000000111;
- while(1){
- if((!input(pin_a0))||(!input(pin_a1))){goto loop ;}
- for(j=0;j<40;j++){
- port_c=0x00;
- delay_ms(50);
- for(i=0;i<2;i++){
- port_d=0x00;
- port_c=0x00;
- delay_ms(50);
- port_d=0x18;
- if(j<5 ){port_c=0x03;}
- if(j>5 && j<10 ){port_c=0x07;}
- if(j>10 && j<25){port_c=0x0f;}
- if(j>25 && j<32){port_c=0xff; port_d=0x0f;}
- if(j>32 && j<40){port_c=0x0f; port_d=0xff;}
- delay_ms(20);
- port_c=0x00;
- delay_ms(50);
- if(j>5 && j<10 ){port_c=0x07;}
- if(j>10 && j<25){port_c=0x0f;}
- if(j>25 && j<32){port_c=0xff; port_d=0x0f;}
- if(j>32 && j<40){port_c=0x0f; port_d=0xff;}
- delay_ms(20);
- }
- if((!input(pin_a0))||(!input(pin_a1))){goto loop ;}
- port_c=0x00;
- delay_ms(50);
- if(j<5 ){port_c=0xc0;}
- if(j>5 && j<10 ){port_c=0xe0;}
- if(j>10 && j<25 ){port_c=0xf0;}
- if(j>25 && j<35){port_c=0xff; port_d=0xf0;}
- if(j>35 && j<40){port_c=0xf0; port_d=0xff;}
- delay_ms(20);
- port_c=0x00;
- delay_ms(50);
- if(j<5 ){port_c=0xc0;}
- if(j>5 && j<10 ){port_c=0xe0;}
- if(j>10 && j<25 ){port_c=0xf0;}
- if(j>25 && j<35){port_c=0xf0; port_d=0xff;}
- if(j>35 && j<40){port_c=0xff; port_d=0xf0;}
- delay_ms(20);
- }
- for(i=0;i<=5;i++){
- k=0b0000000000111;
- for(x=0;x<10;x++){
- k<<=1;
- for(j=0;j<=5;++j){
- if((!input(pin_a0))||(!input(pin_a1))){goto loop ;}
- port_c=k;
- delay_ms(50);
- port_d=0xff;
- delay_ms(20);
- port_d=0x00;;
- }
- }
- if((!input(pin_a0))||(!input(pin_a1))){goto loop ;}
- }
- i=0;
- port_d=0x00;
- port_c=0x00;
- delay_ms(500);
- }
- loop:
- delay_ms(1);
- }
Add Comment
Please, Sign In to add comment