Program No Error
Program No Error
#include <mega16.h>
#include <delay.h>
#include <stdlib.h>
#include <alcd.h>
#define ADC_VREF_TYPE 0x60
// 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;
}
// Declare your global variables here
void main(void)
{
unsigned int adc;
float y;
char temp[6];
PORTD=0x00;
DDRD=0x00;
SPCR=0x00;
lcd_init(16);
lcd_gotoxy(0,0);
lcd_putsf("VISKOSITAS");
lcd_gotoxy(7,1);
lcd_putsf("C");
while (1)
{
// Place your code here
adc=read_adc(0);
y=(float)adc;
lcd_gotoxy(0,1);
ftoa(y,2,temp);
lcd_puts(temp);
}
}
char temp[6];
PORTD=0x00;
DDRD=0x00;
SPCR=0x00;
lcd_init(16);
lcd_gotoxy(0,0);
lcd_putsf("NILAI VISKOSITAS");
lcd_gotoxy(7,1);
lcd_putsf("POISE");
while (1)
{
// Place your code here
adc=read_adc(0);
y=-0.003*(2*(float)adc)+0.19;
lcd_gotoxy(0,1);
ftoa(y,4,temp);
lcd_puts(temp);
}
}