laporan resmi mikrokontroller suhu

3
Program /***************************************************** This program was produced by the CodeWizardAVR V2.05.3 Standard Automatic Program Generator © Copyright 1998-2011 Pavel Haiduc, HP InfoTech s.r.l. http://www.hpinfotech.com Project : Version : Date : 5/2/2016 Author : Atabik Luthfi Company : PENS Comments: Chip type : ATmega16A Program type : Application AVR Core Clock frequency: 8.000000 MHz Memory model : Small External RAM size : 0 Data Stack size : 256 *****************************************************/ #include <mega16a.h> #include <stdio.h> #include <stdlib.h> #include <delay.h> // Alphanumeric LCD functions #include <alcd.h> #asm .equ __lcd_port=0x1B ;PORTB #endasm #define ADC_VREF_TYPE 0x20 // Read the 8 most significant bits // of the AD conversion result unsigned char read_adc(unsigned char adc_input) { ADMUX=adc_input | (ADC_VREF_TYPE & 0xff); // Delay needed for the stabilization of the ADC input voltage delay_us(10); // Start the AD conversion ADCSRA|=0x40; // Wait for the AD conversion to complete while ((ADCSRA & 0x10)==0); ADCSRA|=0x10; return ADCH; } 1

description

Sensor suhu

Transcript of laporan resmi mikrokontroller suhu

Page 1: laporan resmi mikrokontroller suhu

Program/*****************************************************This program was produced by theCodeWizardAVR V2.05.3 StandardAutomatic Program Generator© Copyright 1998-2011 Pavel Haiduc, HP InfoTech s.r.l.http://www.hpinfotech.com

Project : Version : Date : 5/2/2016Author : Atabik LuthfiCompany : PENSComments:

Chip type : ATmega16AProgram type : ApplicationAVR Core Clock frequency: 8.000000 MHzMemory model : SmallExternal RAM size : 0Data Stack size : 256*****************************************************/

#include <mega16a.h>#include <stdio.h>#include <stdlib.h>#include <delay.h>

// Alphanumeric LCD functions#include <alcd.h>#asm .equ __lcd_port=0x1B ;PORTB#endasm#define ADC_VREF_TYPE 0x20

// Read the 8 most significant bits// of the AD conversion resultunsigned char read_adc(unsigned char adc_input){ADMUX=adc_input | (ADC_VREF_TYPE & 0xff);// Delay needed for the stabilization of the ADC input voltagedelay_us(10);// Start the AD conversionADCSRA|=0x40;// Wait for the AD conversion to completewhile ((ADCSRA & 0x10)==0);ADCSRA|=0x10;return ADCH;}

// Declare your global variables here

void main(void){float a, suhu;char temperatur[8];

PORTA=0x00; //ADC DDRA=0x00;

1

Page 2: laporan resmi mikrokontroller suhu

PORTB=0x00; //LCDDDRB=0xFF;

PORTC=0x00; //LEDDDRC=0xFF;

PORTD=0x00; //MOTORDDRD=0xFF;

ADMUX=ADC_VREF_TYPE & 0xff;ADCSRA=0x83;lcd_init(16);lcd_gotoxy(0,0); lcd_putsf("ASSALAMUALAIKUM");lcd_gotoxy(2,1) ; lcd_putsf("Selamat Pagi");delay_ms(3000);lcd_clear();lcd_gotoxy(0,0); lcd_putsf("Have A Nice Day");lcd_gotoxy(3,1);lcd_putsf("=) =) =) =)");delay_ms(3000); lcd_clear;

while (1) { lcd_init(16); a=read_adc(0); PORTC=a; suhu=((float)a*4.2/255)/0.01; lcd_gotoxy(1,0); lcd_putsf("SUHU SAAT INI"); lcd_gotoxy(0,1); lcd_putsf("ADALAH ="); lcd_gotoxy(14,1); lcd_putchar(0xDF); lcd_gotoxy(15,1); lcd_putchar('C'); lcd_putchar(suhu); ftoa(suhu,1,temperatur); lcd_gotoxy(9,1); lcd_puts(temperatur); delay_ms(100); if(suhu<=0x28) PORTD=0x00; else PORTD=0xFF; }}

2

Page 3: laporan resmi mikrokontroller suhu

Gambar Rangkaian

3