SlideShare a Scribd company logo
1 of 6
#include<p18f2550.h><br />#include<delays.h><br />/**D E C L A R A C I O N   D E   F U N C I O N E S ***************************/<br />void send_col(unsigned char x);<br />void enviar_col(unsigned char C);<br />void envia_vector(unsigned char *V, unsigned char t);<br />void send_matriz(unsigned char *V,unsigned char M[8][8]);<br />void envia_matriz(unsigned char M[8][8], unsigned char t);<br />/**D E F I N I C I O N   D E   V A R I A B L E S *****************************/<br />#define PIN_CLOCK   PORTAbits.RA4   // PORT for CLOCK //<br />#define TRIS_CLOCK  DDRAbits.RA4    // TRIS for CLOCK //<br />#define PIN_CLEAR   PORTAbits.RA5   // PORT for CLOCK //<br />#define TRIS_CLEAR  DDRAbits.RA5    // TRIS for CLOCK //<br />#define PIN_DATA    PORTAbits.RA1   // PORT for DATA //<br />#define TRIS_DATA   DDRAbits.RA1    // TRIS for DATA //<br />/**D E C L A R A C I O N   D E   V A R I A B L E S   G L O B A L E S *********/<br />unsigned char V_A[8]   ={0b00111100,0b01111110,0b01100110,0b01100110,0b01111110,0b01111110,0b01100110,0b01100110};<br />unsigned char V_Nulo[8]={0,0,0,0,0,0,0,0};<br />void main (void)<br />{<br />/*************CONFIGURACION DE PUERTOR***************************/<br />ADCON1=0x0F;//Todos entrada/salida Digitales<br />TRISA=0;    //Todos como salida<br />TRISB=0;    //Todos como salida<br />PIN_CLEAR=1;//Si o Si para que la matriz entre en funcionamiento<br />PIN_CLOCK=0;<br />PORTB=0;<br />while(1)<br />{<br />envia_vector(V_A,50);<br />envia_vector(v_Nulo,50);<br />}<br />}<br />void send_col(unsigned char x)<br />{<br />if(x==0)<br />{PIN_DATA=0;}<br />else{PIN_DATA=1;}<br />Delay10TCYx(2);//retardo de 4 microsegundos<br />PIN_CLOCK=0;<br />Delay10TCYx(2);//retardo de 4 microsegundos<br />PIN_CLOCK=1;<br />}<br />void enviar_col(unsigned char C)<br />{<br />int i;<br />for(i=0;i<8;i++)<br />{<br />switch(i)<br />{<br />case 0: send_col(C & 0b00000001);break;<br />case 1: send_col(C & 0b00000010);break;<br />case 2: send_col(C & 0b00000100);break;<br />case 3: send_col(C & 0b00001000);break;<br />case 4: send_col(C & 0b00010000);break;<br />case 5: send_col(C & 0b00100000);break;<br />case 6: send_col(C & 0b01000000);break;<br />case 7: send_col(C & 0b10000000);break;<br />}<br />}<br />}<br />/*--------------------------------------------------------------------------------*/<br />//ENVIAR UNA VECTOR AL DISPLAY<br />void envia_vector(unsigned char *V, unsigned char t)//V:contiene el vector a enviar; t: tiempo de retencion de matriz en el display<br />{<br />unsigned char M_Aux[8][8];<br />send_matriz(V,M_Aux);<br />envia_matriz(M_Aux,t);<br />}<br />//FORMO MATRIZ A PARTIR DE VECTOR--------------------------------<br />void send_matriz(unsigned char *V,unsigned char M[8][8])<br />{<br />unsigned char i,j;<br />int Bits_Peso,aux;<br />for(i=0;i<8;i++)<br />{<br />Bits_Peso=1;<br />for(j=0;j<8;j++)<br />{<br />aux = V[i] & Bits_Peso;<br />if(aux!=0)<br />{<br />aux=1;<br />}<br />M[i][7-j]= aux;<br />Bits_Peso = Bits_Peso*2;<br />}<br />}<br />}<br />/*--------------------------------------------------------------------------------*/<br />//ENVIAR UNA MATRIZ AL DISPLAY<br />void envia_matriz(unsigned char M[8][8], unsigned char t)//M:contiene la matriz a enviar; t: tiempo de retencion de matriz en el display<br />{<br />unsigned char i,j,k,Col;<br />int D,Bits_Peso;<br />for(k=0;k<t;k++)//Tiempo de muestreo de letra<br />{for(j=0;j<8;j++)<br />{<br />Bits_Peso=1;<br />D=0;<br />for(i=8;i>0;i--)<br />{<br />if(M[i-1][j]==1)<br />{<br />D=D+Bits_Peso;<br />}<br />Bits_Peso=Bits_Peso*2;<br />}<br />switch(j)<br />{<br />case 0 : Col=0b10000000;break;<br />case 1 : Col=0b01000000;break;<br />case 2 : Col=0b00100000;break;<br />case 3 : Col=0b00010000;break;<br />case 4 : Col=0b00001000;break;<br />case 5 : Col=0b00000100;break;<br />case 6 : Col=0b00000010;break;<br />case 7 : Col=0b00000001;break;<br />}<br />PORTB=D;//Cargo el valor de las filas<br />enviar_col(~Col);//Cargo el valro de la columna en cuestion<br />Delay1KTCYx(35);//retardo de 2000 microsegundos<br />}<br />}<br />}<br />
Codigo fuente
Codigo fuente
Codigo fuente
Codigo fuente
Codigo fuente

More Related Content

What's hot

Zn task - defcon russia 20
Zn task  - defcon russia 20Zn task  - defcon russia 20
Zn task - defcon russia 20DefconRussia
 
Dam gate open close lpc prog
Dam gate open close lpc progDam gate open close lpc prog
Dam gate open close lpc prognikhil dixit
 
W8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorW8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorDaniel Roggen
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th StudyChris Ohk
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd StudyChris Ohk
 
Ir remote kit_blink.pde
Ir remote kit_blink.pdeIr remote kit_blink.pde
Ir remote kit_blink.pdeCore Pale
 
Cifrado cesar
Cifrado cesarCifrado cesar
Cifrado cesarEIYSC
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th StudyChris Ohk
 
Introduction to Verilog & code coverage
Introduction to Verilog & code coverageIntroduction to Verilog & code coverage
Introduction to Verilog & code coverageJyun-Kai Hu
 
L293D IC interfacing with ATmega16
L293D IC interfacing with ATmega16 L293D IC interfacing with ATmega16
L293D IC interfacing with ATmega16 Varun A M
 
Carry save adder Type 2
Carry save adder Type 2Carry save adder Type 2
Carry save adder Type 2Atchyuth Sonti
 
Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4
Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4
Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4Kaku Tomohiro
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd StudyChris Ohk
 
Fpga 09-behavioral-modeling-moore-machine
Fpga 09-behavioral-modeling-moore-machineFpga 09-behavioral-modeling-moore-machine
Fpga 09-behavioral-modeling-moore-machineMalik Tauqir Hasan
 

What's hot (20)

Zn task - defcon russia 20
Zn task  - defcon russia 20Zn task  - defcon russia 20
Zn task - defcon russia 20
 
Dam gate open close lpc prog
Dam gate open close lpc progDam gate open close lpc prog
Dam gate open close lpc prog
 
W8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational ProcessorW8_2: Inside the UoS Educational Processor
W8_2: Inside the UoS Educational Processor
 
C++ Programming - 11th Study
C++ Programming - 11th StudyC++ Programming - 11th Study
C++ Programming - 11th Study
 
Data Structure - 2nd Study
Data Structure - 2nd StudyData Structure - 2nd Study
Data Structure - 2nd Study
 
Ir remote kit_blink.pde
Ir remote kit_blink.pdeIr remote kit_blink.pde
Ir remote kit_blink.pde
 
Singly Linked List
Singly Linked ListSingly Linked List
Singly Linked List
 
MFC Letter
MFC LetterMFC Letter
MFC Letter
 
Cifrado cesar
Cifrado cesarCifrado cesar
Cifrado cesar
 
Eecs 317 20010209
Eecs 317 20010209Eecs 317 20010209
Eecs 317 20010209
 
C++ Programming - 4th Study
C++ Programming - 4th StudyC++ Programming - 4th Study
C++ Programming - 4th Study
 
Introduction to Verilog & code coverage
Introduction to Verilog & code coverageIntroduction to Verilog & code coverage
Introduction to Verilog & code coverage
 
L293D IC interfacing with ATmega16
L293D IC interfacing with ATmega16 L293D IC interfacing with ATmega16
L293D IC interfacing with ATmega16
 
Carry save adder Type 2
Carry save adder Type 2Carry save adder Type 2
Carry save adder Type 2
 
Carry save adder vhdl
Carry save adder vhdlCarry save adder vhdl
Carry save adder vhdl
 
week-16x
week-16xweek-16x
week-16x
 
Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4
Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4
Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4
 
C++ Programming - 2nd Study
C++ Programming - 2nd StudyC++ Programming - 2nd Study
C++ Programming - 2nd Study
 
StewartPlatform_cpp
StewartPlatform_cppStewartPlatform_cpp
StewartPlatform_cpp
 
Fpga 09-behavioral-modeling-moore-machine
Fpga 09-behavioral-modeling-moore-machineFpga 09-behavioral-modeling-moore-machine
Fpga 09-behavioral-modeling-moore-machine
 

Viewers also liked

Viewers also liked (10)

Tutorial c18
Tutorial c18Tutorial c18
Tutorial c18
 
"Hola Mundo" C18, PIC18F y MPLAB
"Hola Mundo"  C18,  PIC18F y MPLAB"Hola Mundo"  C18,  PIC18F y MPLAB
"Hola Mundo" C18, PIC18F y MPLAB
 
Tutorial mplab 6x[1]
Tutorial mplab 6x[1]Tutorial mplab 6x[1]
Tutorial mplab 6x[1]
 
Parpadear un LED
Parpadear un LEDParpadear un LED
Parpadear un LED
 
Convertidores A/D-D/A
Convertidores A/D-D/AConvertidores A/D-D/A
Convertidores A/D-D/A
 
Curso de-mcu-proteus
Curso de-mcu-proteusCurso de-mcu-proteus
Curso de-mcu-proteus
 
Microcontroladores pic (josé mª angulo usategui, ignacio angulo martínez)
Microcontroladores pic (josé mª angulo usategui, ignacio angulo martínez)Microcontroladores pic (josé mª angulo usategui, ignacio angulo martínez)
Microcontroladores pic (josé mª angulo usategui, ignacio angulo martínez)
 
Microcontroladores pic, diseño práctico de aplicaciones 2da parte 16 f87x
Microcontroladores pic, diseño práctico de aplicaciones 2da parte 16 f87xMicrocontroladores pic, diseño práctico de aplicaciones 2da parte 16 f87x
Microcontroladores pic, diseño práctico de aplicaciones 2da parte 16 f87x
 
Curso de microcontroladores pic18 f4550
Curso de microcontroladores pic18 f4550Curso de microcontroladores pic18 f4550
Curso de microcontroladores pic18 f4550
 
Microcontrolador 1 prender y apagar un led
Microcontrolador 1 prender y apagar un ledMicrocontrolador 1 prender y apagar un led
Microcontrolador 1 prender y apagar un led
 

Similar to Codigo fuente

Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxSANTIAGO PABLO ALBERTO
 
Combine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdfCombine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdfforwardcom41
 
codings related to avr micro controller
codings related to avr micro controllercodings related to avr micro controller
codings related to avr micro controllerSyed Ghufran Hassan
 
Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Svet Ivantchev
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfSIGMATAX1
 
PBL1-v1-002j.pptx
PBL1-v1-002j.pptxPBL1-v1-002j.pptx
PBL1-v1-002j.pptxNAIST
 
c++ project on restaurant billing
c++ project on restaurant billing c++ project on restaurant billing
c++ project on restaurant billing Swakriti Rathore
 
Introduction to Dart
Introduction to DartIntroduction to Dart
Introduction to DartRamesh Nair
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScriptJens Siebert
 
Keypad program
Keypad programKeypad program
Keypad programksaianil1
 
Udp socket programming(Florian)
Udp socket programming(Florian)Udp socket programming(Florian)
Udp socket programming(Florian)Flor Ian
 
Linuxカーネルを読んで改めて知るプロセスとスレッドの違い
Linuxカーネルを読んで改めて知るプロセスとスレッドの違いLinuxカーネルを読んで改めて知るプロセスとスレッドの違い
Linuxカーネルを読んで改めて知るプロセスとスレッドの違いRetrieva inc.
 
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docxAdamq0DJonese
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdffootstatus
 

Similar to Codigo fuente (20)

PIC and LCD
PIC and LCDPIC and LCD
PIC and LCD
 
Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docx
 
Combine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdfCombine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdf
 
Orasta500.c
Orasta500.cOrasta500.c
Orasta500.c
 
codings related to avr micro controller
codings related to avr micro controllercodings related to avr micro controller
codings related to avr micro controller
 
Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016
 
What will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdfWhat will be quantization step size in numbers and in voltage for th.pdf
What will be quantization step size in numbers and in voltage for th.pdf
 
PBL1-v1-002j.pptx
PBL1-v1-002j.pptxPBL1-v1-002j.pptx
PBL1-v1-002j.pptx
 
c++ project on restaurant billing
c++ project on restaurant billing c++ project on restaurant billing
c++ project on restaurant billing
 
Introduction to Dart
Introduction to DartIntroduction to Dart
Introduction to Dart
 
Embedded JavaScript
Embedded JavaScriptEmbedded JavaScript
Embedded JavaScript
 
Lcd n PIC16F
Lcd n PIC16FLcd n PIC16F
Lcd n PIC16F
 
3D-DRESD Lorenzo Pavesi
3D-DRESD Lorenzo Pavesi3D-DRESD Lorenzo Pavesi
3D-DRESD Lorenzo Pavesi
 
Keypad program
Keypad programKeypad program
Keypad program
 
Udp socket programming(Florian)
Udp socket programming(Florian)Udp socket programming(Florian)
Udp socket programming(Florian)
 
Sysprog17
Sysprog17Sysprog17
Sysprog17
 
Linuxカーネルを読んで改めて知るプロセスとスレッドの違い
Linuxカーネルを読んで改めて知るプロセスとスレッドの違いLinuxカーネルを読んで改めて知るプロセスとスレッドの違い
Linuxカーネルを読んで改めて知るプロセスとスレッドの違い
 
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
 
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdfHow do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
How do I draw the Labview code for pneumatic cylinder(air pistion). .pdf
 
Quiz using C++
Quiz using C++Quiz using C++
Quiz using C++
 

Codigo fuente

  • 1. #include<p18f2550.h><br />#include<delays.h><br />/**D E C L A R A C I O N D E F U N C I O N E S ***************************/<br />void send_col(unsigned char x);<br />void enviar_col(unsigned char C);<br />void envia_vector(unsigned char *V, unsigned char t);<br />void send_matriz(unsigned char *V,unsigned char M[8][8]);<br />void envia_matriz(unsigned char M[8][8], unsigned char t);<br />/**D E F I N I C I O N D E V A R I A B L E S *****************************/<br />#define PIN_CLOCK PORTAbits.RA4 // PORT for CLOCK //<br />#define TRIS_CLOCK DDRAbits.RA4 // TRIS for CLOCK //<br />#define PIN_CLEAR PORTAbits.RA5 // PORT for CLOCK //<br />#define TRIS_CLEAR DDRAbits.RA5 // TRIS for CLOCK //<br />#define PIN_DATA PORTAbits.RA1 // PORT for DATA //<br />#define TRIS_DATA DDRAbits.RA1 // TRIS for DATA //<br />/**D E C L A R A C I O N D E V A R I A B L E S G L O B A L E S *********/<br />unsigned char V_A[8] ={0b00111100,0b01111110,0b01100110,0b01100110,0b01111110,0b01111110,0b01100110,0b01100110};<br />unsigned char V_Nulo[8]={0,0,0,0,0,0,0,0};<br />void main (void)<br />{<br />/*************CONFIGURACION DE PUERTOR***************************/<br />ADCON1=0x0F;//Todos entrada/salida Digitales<br />TRISA=0; //Todos como salida<br />TRISB=0; //Todos como salida<br />PIN_CLEAR=1;//Si o Si para que la matriz entre en funcionamiento<br />PIN_CLOCK=0;<br />PORTB=0;<br />while(1)<br />{<br />envia_vector(V_A,50);<br />envia_vector(v_Nulo,50);<br />}<br />}<br />void send_col(unsigned char x)<br />{<br />if(x==0)<br />{PIN_DATA=0;}<br />else{PIN_DATA=1;}<br />Delay10TCYx(2);//retardo de 4 microsegundos<br />PIN_CLOCK=0;<br />Delay10TCYx(2);//retardo de 4 microsegundos<br />PIN_CLOCK=1;<br />}<br />void enviar_col(unsigned char C)<br />{<br />int i;<br />for(i=0;i<8;i++)<br />{<br />switch(i)<br />{<br />case 0: send_col(C & 0b00000001);break;<br />case 1: send_col(C & 0b00000010);break;<br />case 2: send_col(C & 0b00000100);break;<br />case 3: send_col(C & 0b00001000);break;<br />case 4: send_col(C & 0b00010000);break;<br />case 5: send_col(C & 0b00100000);break;<br />case 6: send_col(C & 0b01000000);break;<br />case 7: send_col(C & 0b10000000);break;<br />}<br />}<br />}<br />/*--------------------------------------------------------------------------------*/<br />//ENVIAR UNA VECTOR AL DISPLAY<br />void envia_vector(unsigned char *V, unsigned char t)//V:contiene el vector a enviar; t: tiempo de retencion de matriz en el display<br />{<br />unsigned char M_Aux[8][8];<br />send_matriz(V,M_Aux);<br />envia_matriz(M_Aux,t);<br />}<br />//FORMO MATRIZ A PARTIR DE VECTOR--------------------------------<br />void send_matriz(unsigned char *V,unsigned char M[8][8])<br />{<br />unsigned char i,j;<br />int Bits_Peso,aux;<br />for(i=0;i<8;i++)<br />{<br />Bits_Peso=1;<br />for(j=0;j<8;j++)<br />{<br />aux = V[i] & Bits_Peso;<br />if(aux!=0)<br />{<br />aux=1;<br />}<br />M[i][7-j]= aux;<br />Bits_Peso = Bits_Peso*2;<br />}<br />}<br />}<br />/*--------------------------------------------------------------------------------*/<br />//ENVIAR UNA MATRIZ AL DISPLAY<br />void envia_matriz(unsigned char M[8][8], unsigned char t)//M:contiene la matriz a enviar; t: tiempo de retencion de matriz en el display<br />{<br />unsigned char i,j,k,Col;<br />int D,Bits_Peso;<br />for(k=0;k<t;k++)//Tiempo de muestreo de letra<br />{for(j=0;j<8;j++)<br />{<br />Bits_Peso=1;<br />D=0;<br />for(i=8;i>0;i--)<br />{<br />if(M[i-1][j]==1)<br />{<br />D=D+Bits_Peso;<br />}<br />Bits_Peso=Bits_Peso*2;<br />}<br />switch(j)<br />{<br />case 0 : Col=0b10000000;break;<br />case 1 : Col=0b01000000;break;<br />case 2 : Col=0b00100000;break;<br />case 3 : Col=0b00010000;break;<br />case 4 : Col=0b00001000;break;<br />case 5 : Col=0b00000100;break;<br />case 6 : Col=0b00000010;break;<br />case 7 : Col=0b00000001;break;<br />}<br />PORTB=D;//Cargo el valor de las filas<br />enviar_col(~Col);//Cargo el valro de la columna en cuestion<br />Delay1KTCYx(35);//retardo de 2000 microsegundos<br />}<br />}<br />}<br />