'********************************************************
'* *
'* ADC PROJECT FOR USE WITH BOOST BASIC *
'* *
'* WRITTEN BY : PUNERJOT SINGH MANGAT *
'* COUNTRY : INDIA *
'* CITY : PATIALA *
'* WEB PAGE : www.rackeys.com/punerjot *
'* EMAIL : punerjot@rackeys.com *
'* SOURCEBOOST ID : c58_4311 *
'* RELEASE DATE : March 03, 2006 *
'* REVISED DATE : May 24, 2006 *
'* *
'********************************************************
'
'
'
'This project file demonstrates the use of the adcbaslib.bas file for reading the temperature sensor
'LM35 and displaying the temperature on the lcd. The ADC is read at every 1/2 seconds.
'
'
' +-------+
' | |
' | LM35 |
' | |
' +-------+
' | | |
' | | |
' | | |
' + * -
'
' From above diagram : (+) = +5V
' (-) = gnd
' (*) = RA0 pin of PORTA of 16f877A
'
'
'
'******************************** reading the LM35 starts ********************************
function temperature() as byte
temperature = (call adc_read()) / 2
end function
'********************************* reading the LM35 ends *********************************
'******************************** displaying a byte on the lcd starts ********************************
sub display_byte( a as byte)
call lcd_putch(48 + (a / 100))
call lcd_putch(48 + ((a mod 100) / 10))
call lcd_putch(48 + (a mod 10))
end sub
'********************************* displaying a byte on the lcd ends *********************************
Sub main()
trisa = ( 00000001b ) 'pin A0 as input for analog input
call adc_init() 'initialize the adc port
call lcd_init() 'initialize the lcd
call lcd_clear() 'clears the lcd
Do while 1
call display_byte( call temperature() ) 'displays the temperature
call lcd_putch(67) 'displays char "C" as centigrade
call delay_ms(500) 'delay to take readings after 1/2 seconds
Loop
end Sub
Copyright © 2006 SourceBoost Technologies