Hi,
Try that on your breadboard.
(Click to enlarge the picture)
The original tutorial + code can be found here:
http://www.rentron.com/PicBasic/LM34.htm
LM35 datasheet:
http://www.national.com/ds/LM/LM35.pdf
The code below will work with the above connections.
Note that you will have to add the DEFINE + code for the LCD.
Best regards,
Luciano
Code:DEFINE osc 4 ' We're using a 4 MHz oscillator DEFINE ADC_BITS 8 ' Set A/D for 8-bit operation DEFINE ADC_CLOCK 1 ' Set A/D clock Fosc/8 DEFINE ADC_SAMPLEUS 50 ' Set A/D sampling time @ 50 uS ' Add the LCD DEFINEs here <<<<<<<<<<<<<<<<<<<<<<<<< samples VAR WORD ' Multiple A/D sample accumulator sample VAR BYTE ' Holds number of samples to take temp VAR BYTE ' Temperature storage samples = 0 ' Clear samples accumulator on power-up TRISA = %11111111 ' Set PORTA to all input ADCON1 = %00000011 ' Set PORTA.0,1,2,5 = A/D, PortA.3 = +Vref PAUSE 500 ' Wait .5 second loop: FOR sample = 1 TO 20 ' Take 20 samples ADCIN 0, temp ' Read channel 0 into temp variable samples = samples + temp ' Accumulate 20 samples PAUSE 250 ' Wait approximately 1/4 seconds per loop NEXT sample temp = samples/20 LCDOUT $FE, 1 ' Clear LCD LCDOUT "Temp: ",DEC temp,"'C" samples = 0 ' Clear old sample accumulator GOTO loop ' Do it forever END
Bookmarks