mbprado
Newbie level 3
Hi everyone.
I have seen in another topic, an exemple in mikrobasic, of a 0v > +5v voltimeter .
Thamid's exemple bellow, works fine for me, but now, I need to work at -5v to +5v and I dont know how to do this.
Any Idea?
Tks for your help.
I have seen in another topic, an exemple in mikrobasic, of a 0v > +5v voltimeter .
Thamid's exemple bellow, works fine for me, but now, I need to work at -5v to +5v and I dont know how to do this.
Any Idea?
Tks for your help.
Code:
program softwarefor887Voltmeter
dim LCD_RS as sbit at RB4_bit
LCD_EN as sbit at RB5_bit
LCD_D4 as sbit at RB0_bit
LCD_D5 as sbit at RB1_bit
LCD_D6 as sbit at RB2_bit
LCD_D7 as sbit at RB3_bit
LCD_RS_Direction as sbit at TRISB4_bit
LCD_EN_Direction as sbit at TRISB5_bit
LCD_D4_Direction as sbit at TRISB0_bit
LCD_D5_Direction as sbit at TRISB1_bit
LCD_D6_Direction as sbit at TRISB2_bit
LCD_D7_Direction as sbit at TRISB3_bit
dim ADCResult as longword
dim voltage as word[5]
dim display as string[5]
sub procedure GlobInit
ANSEL = 1
ANSELH = 0
TRISA = 1
TRISB = 0
PORTB = 0
LCD_Init()
LCD_Cmd(_LCD_CLEAR)
LCD_Cmd(_LCD_CURSOR_OFF)
LCD_Out(1, 1, "Voltage:")
LCD_Chr(1, 16, "V")
display[1] = "."
end sub
main:
GlobInit
while true
ADCResult = (ADC_Read(0) * 500) >> 10
voltage[0] = ADCResult div 100
voltage[1] = (ADCResult div 10) mod 10
voltage[2] = ADCResult mod 10
display[0] = voltage[0] + 48
display[2] = voltage[1] + 48
display[3] = voltage[2] + 48
vout:
LCD_Out(1, 10, display)
delay_ms(50)
wend
end.