TODOPIC
Microcontroladores PIC => Lenguaje Basic para microcontroladores PIC => Mensaje iniciado por: Skelton en 31 de Octubre de 2019, 20:22:49
-
Buenas tardes a todos las personas del foro.
Tengo una duda respecto a este código realizado en proton ide (lenguaje basic) y es que, el código me funciona todo bien en cuanto a mostrar las distintas temperaturas en la LCD, pero necesito que cuando el sensor detecte la temperatura de 30 grados celsius, me imprima el mensaje ''¡Alerta!'' con el valor en grados celsius.
Adjunto código y foto de la simulación en proteus
Device = 16F877A 'DECLARAMOS EL PIC A USAR
XTAL = 4 'CRYSTAL DE 4Mhz
Declare LCD_TYPE 0 'DECLARAMOS LOS PUERTOS DE SALIDA Y DE PROGRAMACIÓN.
Declare LCD_DTPIN PORTD.4
Declare LCD_RSPIN PORTD.2
Declare LCD_ENPIN PORTD.3
LCD_LINES 2
TRISD=0 'PUERTO D COMO SALIDA.
TRISA.0=1 'PUERTO A.0 COMO ENTRADA ANALOGICA.
ADCON1=%100000
Dim adc As Float
Dim resultado As Float
Print At 1,1, " SENSOR DE " 'FRASES AL COMENSAR LA PROGRAMACION.
Print At 2,1, "TEMPERATURA LM35"
DelayMS 3000
Print At 1,1, " "
Print At 2,1, " "
DelayMS 500
Print At 1,1, " PROGRAMADO CON "
Print At 2,1, " PIC 16F877A "
DelayMS 3000
Print At 1,1, " "
Print At 2,1, " "
DelayMS 500
inicio:
Print At 1,1, " TEMPERATURA " 'EN LA PRIMERA FILA LA PALABRA TEMPERATURA.
Print At 2,1, "ACTUAL" 'FILA 2 PALABRA ACTUAL ASTA COLUMNA 8.
adc = ADIn 0
resultado = adc * 500/65472 'AQUÍ APARECE LA TEMPERATURA.
Print At 2,8,DEC1,resultado,0
Print At 2,12,"'C "
GoTo inicio
End
trate de solucionarlo insertandole esto:
If resultado = 30.3 Then
Print At 1,1, " ¡ALERTA! "
Print At 2,8,DEC1,resultado,0
End If
pero no funciona. Soy un poco novato en el entorno aun.
Foto simulacion: https://www36.zippyshare.com/v/D0t5xIca/file.html
-
Que tal Skeleton:
Sería algo así:
Device = 16F877A 'DECLARAMOS EL PIC A USAR
Xtal = 4 'CRYSTAL DE 4Mhz
Declare LCD_Type 0 'DECLARAMOS LOS PUERTOS DE SALIDA Y DE PROGRAMACIÓN.
Declare LCD_DTPin PORTD.4
Declare LCD_RSPin PORTD.2
Declare LCD_ENPin PORTD.3
Declare LCD_Lines 2
TRISD=0 'PUERTO D COMO SALIDA.
TRISA.0=1 'PUERTO A.0 COMO ENTRADA ANALOGICA.
ADCON1=%100000
Dim adc As Float
Dim resultado As Float
Print At 1,1, " SENSOR DE " 'FRASES AL COMENSAR LA PROGRAMACION.
Print At 2,1, "TEMPERATURA LM35"
DelayMS 3000
Print At 1,1, " PROGRAMADO CON "
Print At 2,1, " PIC 16F877A "
DelayMS 3000
inicio:
adc = ADIn 0
resultado = adc * 500/65472 'AQUÍ APARECE LA TEMPERATURA.
If resultado < 30 Then
Print At 1,1, " TEMPERATURA " 'EN LA PRIMERA FILA LA PALABRA TEMPERATURA.
Print At 2,1, "ACTUAL " 'FILA 2 PALABRA ACTUAL ASTA COLUMNA 8.
Print At 2,8,Dec1,resultado,0
Print %11011111 'Imprime el símvolo de grados
Print "C"
Else
Print At 1,1, " ALERTA! "
Print At 2,1, " "
Print At 2,5,Dec1,resultado,0
Print %11011111 'Imprime el símbolo de grados
Print "C "
EndIf
GoTo inicio
End
saludos,
elreypic.
-
Muchas gracias, funciono a la perfección, saludos!.