LM35, in principle, given the voltage + Vs and GND, the voltage Vout will issue of
Vout = surrounding temperature (centigrade) x 10mV.
on the # include “lcd.h” you can download click here.
This is source code from this project in AVR-GCC format.
#include
#include
#include
#include
#include “lcd.h” //header lcd
volatile unsigned char suhu; //variabel store adc
//deklarasi lcd to stdio
static int lcd_putchar(char c, FILE *stream); //prototype
static FILE mystdout = FDEV_SETUP_STREAM(lcd_putchar, NULL,_FDEV_SETUP_WRITE); static int lcd_putchar(char c, FILE *stream)
{
if (c == ‘\n’) lcd_putchar(’\r’, stream);
LCD_send_char(c);
return(0);
}
//fungsi delay mili sekon
void delay_ms(int ms)
{for(int i=0;i<=ms;i++){_delay_ms(1);};
}
void adc_init(void) //inisialisasi lcd
{ ADMUX =(1<<
|(1<
|(0<<<<
ADCSRA =(1<<<
|(1<<<
sei ();
}
ISR(ADC_vect)
{ suhu=ADCH;
LCD_send_command(0xc0); //cursor line2
printf(”sekarang:%3d c”,suhu);
return;
}
int main (void)
{ adc_init();
delay_ms(200);
LCD_init();
stdout = &mystdout;
LCD_send_command(LCD_CLR);
LCD_send_command(LCD_HOME);
LCD_send_command(0×80); //cursor line1
printf(”suhu ruangan ini”);
LCD_send_command(0xc0); //cursor line2
printf(”sekarang:%3d c “,suhu);
while(1){
ADCSRA|=(1<
delay_ms(500);
}
return(0);
}
Vout = surrounding temperature (centigrade) x 10mV.
on the # include “lcd.h” you can download click here.
This is source code from this project in AVR-GCC format.
#include
#include
#include
#include
#include “lcd.h” //header lcd
volatile unsigned char suhu; //variabel store adc
//deklarasi lcd to stdio
static int lcd_putchar(char c, FILE *stream); //prototype
static FILE mystdout = FDEV_SETUP_STREAM(lcd_putchar, NULL,_FDEV_SETUP_WRITE); static int lcd_putchar(char c, FILE *stream)
{
if (c == ‘\n’) lcd_putchar(’\r’, stream);
LCD_send_char(c);
return(0);
}
//fungsi delay mili sekon
void delay_ms(int ms)
{for(int i=0;i<=ms;i++){_delay_ms(1);};
}
void adc_init(void) //inisialisasi lcd
{ ADMUX =(1<
|(1<
|(0<
ADCSRA =(1<
|(1<
sei ();
}
ISR(ADC_vect)
{ suhu=ADCH;
LCD_send_command(0xc0); //cursor line2
printf(”sekarang:%3d c”,suhu);
return;
}
int main (void)
{ adc_init();
delay_ms(200);
LCD_init();
stdout = &mystdout;
LCD_send_command(LCD_CLR);
LCD_send_command(LCD_HOME);
LCD_send_command(0×80); //cursor line1
printf(”suhu ruangan ini”);
LCD_send_command(0xc0); //cursor line2
printf(”sekarang:%3d c “,suhu);
while(1){
ADCSRA|=(1<
delay_ms(500);
}
return(0);
}
No comments:
Post a Comment