TODOPIC
Microcontroladores PIC => Lenguaje Basic para microcontroladores PIC => Mensaje iniciado por: masterpiano en 10 de Enero de 2011, 15:25:54
-
Hola amigos, necesito ayuda con el siguiente codigo, estoy haciendo un voltimetro que me envie un mensaje a cada estado de la bateria del auto, yolo resolvi de una manera un poco extrema, y quisiera saber si alguein me puede ayudar a resolverlo de otra manera alli les dejo el co'****************************************************************
'* Name : Voltimetro inteligente *
'* Author : gerardo salazar *
'* Notice : diseñado para reanult fuego *
'* : All Rights Reserved *
'* Date : 09/01/2011 *
'* Version : 1.0 *
'* Notes : *
'* : *
'****************************************************************
define osc 10
define lcd_dreg portd
define lcd_bits 4
define lcd_dbit 4
define lcd_rsreg portb
define lcd_rsbit 1
define lcd_ereg portb
define lcd_ebit 0
define lcd_lines 2
define ADC_bits 10
define adc_sampleus 50
A var word
temp var word
adcon1 = %10000000
lcdout $fe,1
inicio:
adcin 0,A
temp = (A */ 1500)>>2
lcdout $fe,2,"Voltaje=", DEC (temp/100),".", DEC2 temp, "V"'mostrar en LCD
if A < 809 then lcdout $fe,$c0," Descargada"
if A = 810 then lcdout $fe,$c0," Bateria 20%"
if A = 811 then lcdout $fe,$c0," Bateria 20%"
if A = 812 then lcdout $fe,$c0," Bateria 20%"
if A = 813 then lcdout $fe,$c0," Bateria 20%"
if A = 814 then lcdout $fe,$c0," Bateria 20%"
if A = 815 then lcdout $fe,$c0," Bateria 20%"
if A = 816 then lcdout $fe,$c0," Bateria 20%"
if A = 817 then lcdout $fe,$c0," Bateria 20%"
if A = 818 then lcdout $fe,$c0," Bateria 20%"
if A = 819 then lcdout $fe,$c0," Bateria 20%"
if A = 820 then lcdout $fe,$c0," Bateria 20%"
if A = 821 then lcdout $fe,$c0," Bateria 20%"
if A = 822 then lcdout $fe,$c0," Bateria 20%"
if A = 823 then lcdout $fe,$c0," Bateria 20%"
if A = 824 then lcdout $fe,$c0," Bateria 20%"
if A = 825 then lcdout $fe,$c0," Bateria 25%"
if A = 826 then lcdout $fe,$c0," Bateria 25%"
if A = 827 then lcdout $fe,$c0," Bateria 25%"
if A = 828 then lcdout $fe,$c0," Bateria 25%"
if A = 829 then lcdout $fe,$c0," Bateria 25%"
if A = 830 then lcdout $fe,$c0," Bateria 25%"
if A = 831 then lcdout $fe,$c0," Bateria 25%"
if A = 832 then lcdout $fe,$c0," Bateria 25%"
if A = 833 then lcdout $fe,$c0," Bateria 25%"
if A = 834 then lcdout $fe,$c0," Bateria 25%"
if A = 835 then lcdout $fe,$c0," Bateria 25%"
if A = 836 then lcdout $fe,$c0," Bateria 25%"
if A = 837 then lcdout $fe,$c0," Bateria 25%"
if A = 838 then lcdout $fe,$c0," Bateria 25%"
if A = 839 then lcdout $fe,$c0," Bateria 50%"
if A = 841 then lcdout $fe,$c0," Bateria 50%"
if A = 842 then lcdout $fe,$c0," Bateria 50%"
if A = 843 then lcdout $fe,$c0," Bateria 50%"
if A = 844 then lcdout $fe,$c0," Bateria 50%"
if A = 845 then lcdout $fe,$c0," Bateria 50%"
if A = 846 then lcdout $fe,$c0," Bateria 50%"
if A = 847 then lcdout $fe,$c0," Bateria 50%"
if A = 848 then lcdout $fe,$c0," Bateria 50%"
if A = 849 then lcdout $fe,$c0," Bateria 50%"
if A = 850 then lcdout $fe,$c0," Bateria 50%"
if A = 851 then lcdout $fe,$c0," Bateria 50%"
if A = 852 then lcdout $fe,$c0," Bateria 75%"
if A = 853 then lcdout $fe,$c0," Bateria 75%"
if A = 854 then lcdout $fe,$c0," Bateria 75%"
if A = 855 then lcdout $fe,$c0," Bateria 75%"
if A = 856 then lcdout $fe,$c0," Bateria 75%"
if A = 857 then lcdout $fe,$c0," Bateria 75%"
if A = 858 then lcdout $fe,$c0," Bateria 75%"
if A = 859 then lcdout $fe,$c0," Bateria 75%"
if A = 860 then lcdout $fe,$c0," Bateria 75%"
if A = 861 then lcdout $fe,$c0," Bateria 75%"
if A = 862 then lcdout $fe,$c0," Bateria 75%"
if A = 863 then lcdout $fe,$c0," Bateria 75%"
if A = 864 then lcdout $fe,$c0," Bateria 75%"
if A = 865 then lcdout $fe,$c0," Bateria 75%"
if A = 866 then lcdout $fe,$c0," Bateria 100%"
if A = 867 then lcdout $fe,$c0," Bateria 100%"
if A = 868 then lcdout $fe,$c0," Bateria 100%"
if A = 869 then lcdout $fe,$c0," Bateria 100%"
if A = 870 then lcdout $fe,$c0," Bateria 100%"
if A = 871 then lcdout $fe,$c0," Bateria 100%"
if A = 872 then lcdout $fe,$c0," Bateria 100%"
if A = 873 then lcdout $fe,$c0," Bateria 100%"
if A = 874 then lcdout $fe,$c0," Bateria 100%"
if A = 875 then lcdout $fe,$c0," Bateria 100%"
if A = 876 then lcdout $fe,$c0," Bateria 100%"
if A = 877 then lcdout $fe,$c0," Bateria 100%"
if A = 878 then lcdout $fe,$c0," Bateria 100%"
if A = 879 then lcdout $fe,$c0," Bateria 100%"
if A = 880 then lcdout $fe,$c0," Bateria 100%"
if A > 881 then lcdout $fe,$c0," Cargando"
gOTO INICIO
end
digo, gracias de ante mano y saludos...
-
Si la verdad si tienes un intervalo podrias hacer algo parecido a:
if A>809 and A<824 then lcdout $fe,$c0," Bateria 20%".
Un Saludo.
-
gracias amigo
resuelto el problema
era mejor asi que ese poco de lineas
gracias deverdad
saludos desde venezuela