Member baru? Bingung? Perlu bantuan? Silakan baca panduan singkat untuk ikut berdiskusi.

Selamat datang, Pengunjung. Silahkan masuk atau mendaftar. Apakah anda lupa aktivasi email?

Maret 05, 2021, 05:25:45 PM

Masuk dengan nama pengguna, kata sandi dan lama sesi

Topik Baru

Artikel Sains

Anggota
  • Total Anggota: 26699
  • Latest: Rion
Stats
  • Total Tulisan: 139621
  • Total Topik: 10384
  • Online Today: 44
  • Online Ever: 441
  • (Desember 18, 2011, 12:48:51 AM)
Pengguna Online
Users: 0
Guests: 60
Total: 60

Ikuti ForSa

ForSa on FB ForSa on Twitter

Penulis Topik: tampilan di LCD memakai sensor suhu LM35 berbasis atmega8535  (Dibaca 8272 kali)

0 Anggota dan 1 Pengunjung sedang melihat topik ini.

Offline kurnia prana

  • Mahasiswa
  • **
  • Tulisan: 10
  • IQ: 7
tampilan di LCD memakai sensor suhu LM35 berbasis atmega8535
« pada: Januari 03, 2011, 11:19:38 AM »
ada yang tau ga program bahasa C untuk nampilin suhu di LCD 2x16 memakai atmega 8535?? please help me!!!

Offline N.A.T.O

  • Mahasiswa
  • **
  • Tulisan: 21
  • IQ: 2
Re: tampilan di LCD memakai sensor suhu LM35 berbasis atmega8535
« Jawab #1 pada: April 12, 2011, 02:38:26 PM »
/*****************************************************
This program was produced by the
CodeWizardAVR V1.25.9 Standard
Automatic Program Generator
© Copyright 1998-2008 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project :
Version :
unsigned int SUHU;
 char sementara[16];
 float suhu_c;

#include <mega8535.h>
#include <stdlib.h>

// Alphanumeric LCD Module functions
#asm
   .equ __lcd_port=0x15 ;PORTC
#endasm
#include <lcd.h>

// Standard Input/Output functions
#include <stdio.h>

#include <delay.h>

#define ADC_VREF_TYPE 0x40

// Read the AD conversion result
unsigned int 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 ADCW;
}

// Declare your global variables here

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

PORTB=0x00;
DDRB=0x00;

PORTC=0x00;
DDRC=0x00;

PORTD=0x00;
DDRD=0x00;

// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
// Mode: Normal top=FFh
// OC0 output: Disconnected
TCCR0=0x00;
TCNT0=0x00;
OCR0=0x00;

// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1A output: Discon.
// OC1B output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;

// Timer/Counter 2 initialization
// Clock source: System Clock
// Clock value: Timer 2 Stopped
// Mode: Normal top=FFh
// OC2 output: Disconnected
ASSR=0x00;
TCCR2=0x00;
TCNT2=0x00;
OCR2=0x00;

// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
// INT2: Off
MCUCR=0x00;
MCUCSR=0x00;

// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;

// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x4D;

// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
SFIOR=0x00;

// ADC initialization
// ADC Clock frequency: 750.000 kHz
// ADC Voltage Reference: AVCC pin
// ADC High Speed Mode: Off
// ADC Auto Trigger Source: None
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x84;
SFIOR&=0xEF;

lcd_init(16);


while (1)
      {
        SUHU= read_adc(0);
        suhu_c=(float)SUHU*500/1023;
        sprintf(sementara,"%i",SUHU);
        lcd_clear( );lcd_gotoxy(0,0);
        lcd_puts(sementara);
        ftoa(suhu_c,1,sementara);
        lcd_gotoxy(0,1) ;
        lcd_puts(sementara);
   delay_ms(500);
      };
}

 

Related Topics

  Subyek / Dimulai oleh Jawaban Tulisan terakhir
3 Jawaban
5895 Dilihat
Tulisan terakhir Januari 05, 2010, 07:25:12 PM
oleh coys
6 Jawaban
7047 Dilihat
Tulisan terakhir Juni 28, 2010, 12:52:44 PM
oleh nissan_genesis
0 Jawaban
170940 Dilihat
Tulisan terakhir Maret 12, 2016, 10:20:54 AM
oleh KevinM.K
0 Jawaban
177527 Dilihat
Tulisan terakhir Maret 12, 2016, 10:36:29 AM
oleh KevinM.K
0 Jawaban
169379 Dilihat
Tulisan terakhir April 05, 2016, 02:42:52 AM
oleh KevinM.K