//************************************************************
// Function: Temperature logger: UART at 9600 baud
// Processor: PIC16F628 at 4 MHz using internal RC oscillator
// Hardware: K4
// Software: CCS PCM
// Author: Cheruiyot Felix, felix@nairobicoder.com
// Credit: Lars Petersen, oz1bxm@pobox.com
//************************************************************
#include <16F628.h>
#fuses INTRC_IO, NOLVP, NOWDT, PUT, BROWNOUT
#device ADC=8;
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=pin_B2, rcv=pin_B1)
void main() {
//Initialize values
unsigned int val;
int t;
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(0);
while(read_adc()) {
val=read_adc();
t=round(val*0.48876); //as per http://www.best-microcontroller-projects.com/temperature-recorder.html tutorial
delay_ms(500);
printf("T%d",t); //Output temperature
}
}