Suhu Code.docx

  • Uploaded by: syerly
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Suhu Code.docx as PDF for free.

More details

  • Words: 94
  • Pages: 3
#include <mega32.h> #include <delay.h> unsigned char angka[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};

int satuan,puluhan,koma,data_adc,data_temp,x; int Vref=1.2; float suhu,tegangan_input,tampung;

#define ADC_VREF_TYPE 0x00 unsigned int read_adc(unsigned char adc_input) { ADMUX=adc_input|(ADC_VREF_TYPE&0xff);

delay_us(10); ADCSRA|=0x40; while((ADCSRA&0x10)==0); ADCSRA|=10; return ADCW; }

void tampilkan() { data_temp=(int)suhu; koma=data_temp%10; satuan=(data_temp/10)%10; puluhan=(data_temp/100)%10;

PORTB.0=0;

PORTB.1=1; PORTB.2=1; PORTC=angka[puluhan]; delay_ms(5);

PORTB.0=1; PORTB.1=0; PORTB.2=1; PORTC=angka[satuan]; delay_ms(5);

PORTB.0=1; PORTB.1=1; PORTB.2=0; PORTC=angka[koma]; delay_ms(5); }

void baca_data() { tampung=0; for(x=0;x<100;x++) { data_adc=read_adc(0); tampung = tampung+data_adc; tampilkan(); } tampung = tampung/100; tegangan_input = (float)tampung * Vref / 1023;

suhu=tegangan_input*1000; }

void main(void) { PORTA=0x00; DDRA=0x00;

PORTC=0x00; DDRC=0xFF;

PORTB=0xFF; DDRB=0xFF;

ADMUX=ADC_VREF_TYPE&0xFF; ADCSRA=0x84; SFIOR&=0xFF;

while(1) {

baca_data(); } }

Related Documents

Suhu
June 2020 38
Suhu Kulkas.xlsx
July 2020 22
Suhu Kulkas.docx
December 2019 49
Suhu Kulkas.xlsx
December 2019 50
Suhu Code.docx
May 2020 25
Suhu Kulkas.xlsx
December 2019 42

More Documents from "ELIN"