Professional Documents
Culture Documents
Lab 1
Lab 1
Lab 1
Variables
globales
int adc=0;
float adc1=0;
char txt1;
char txt[15];
char tecla;
int aux=0;
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Inicilalizacion
del PWMy LCD
ADC_Init();
PWM1_Init(5000);
PWM1_Start();
Lcd_Init();
adc = ADC_Read(0);
delay_ms(50);
adc=adc*0.0977517106;
inttostr(adc,txt);
lcd_out(1,8,txt);
lcd_out(1,14,"[%]");
adc = ADC_Read(0);
delay_ms(50);
adc=adc*0.0977517106;
inttostr(adc,txt);
lcd_out(1,8,txt);
lcd_out(1,14,"[%]");
Creacion del
teclado
Matricial Filas-
Columnas
PORTB.f4=0;
if(PORTB.F0==0) tecla='1';
if(PORTB.F1==0) tecla='2';
if(PORTB.F2==0) tecla='3';
if(PORTB.F3==0) tecla='A';
PORTB.f4=1;
PORTB.f5=0;
Text
if(PORTB.F0==0) tecla='4';
if(PORTB.F1==0) tecla='5';
if(PORTB.F2==0) tecla='6';
if(PORTB.F3==0) tecla='B';
PORTB.f5=1;
PORTB.f6=0;
if(PORTB.F0==0) tecla='7';
if(PORTB.F1==0) tecla='8';
if(PORTB.F2==0) tecla='9';
if(PORTB.F3==0) tecla='C';
PORTB.f6=1;
PORTB.f7=0;
if(PORTB.F0==0) tecla='*';
if(PORTB.F1==0) tecla='0';
if(PORTB.F2==0) tecla='#';
if(PORTB.F3==0) tecla='D';
PORTB.f7=1;
Lcd_Chr(2, 16, tecla);
No
tecla=='A'
Si
lcd_out(2,1,"Start");
aux=1;
PWM1_Set_Duty(adc*2.55);
No
tecla=='B'
Si
lcd_out(2,1,"Stop ");
PWM1_Set_Duty(0);
aux=0;
No
tecla=='C'
Si
lcd_out(2,7,"IZQ ");
PORTC.F0=1;
PORTC.F1=0;
No
tecla=='D'
Si
lcd_out(2,7,"DER ");
PORTC.F0=0;
PORTC.F1=1;
No
aux==1
Si
PWM1_Set_Duty(adc*2.55);
No
aux==0
Si
PWM1_Set_Duty(0);
Bucle =1
Fin