Академический Документы
Профессиональный Документы
Культура Документы
Saat Besar Analog sebesar 1 V maka pada LED 8 bit bernilai 00110011
Besaran
Analog
Besaran Digital
Biner
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
0V
0.05 V
0.1 V
0.2 V
0.3 V
0.4 V
0.5 V
0.6 V
0.7 V
0.8 V
0.9 V
1V
1.5 V
2V
2.5 V
3V
3.5 V
4V
4.5 V
5V
0000 0000
0000 0010
0000 0101
0000 1010
0000 1111
0001 0100
0001 1001
0001 1110
0010 0011
0010 1001
0010 1110
0011 0011
0100 1100
0110 0110
1000 0000
1001 1001
1011 0011
1100 1100
1110 0110
1111 1111
PERCOBAAN 2
Membaca data ADC dan ditampilkan datanya ke display LCD dalam bentuk BAR
#include <mega128.h>
#include <delay.h>
#include <alcd.h>
#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;
}
// Declare your global variables here
void main(void)
{
int a,n,j;
PORTA=0x00;
DDRA=0xFF;
// ADC initialization
// ADC Clock frequency: 1000.000 kHz
// ADC Voltage Reference: AREF pin
// Only the 8 most significant bits of
// the AD conversion result are used
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x83;
lcd_init(16);
while (1)
{
a=read_adc(0);
n=a/(255/14);
lcd_clear();
lcd_putchar('E');
lcd_gotoxy(15,0);
lcd_putchar('F');
lcd_gotoxy(1,0);
for(j=1;j<=n;j++)
{
lcd_putchar(255);
}
delay_ms(300);
}
}
PERCOBAAN 3
Membaca data ADC dan ditampilkan datanya ke LCD dalam bentuk angka desimal
#include <mega128.h>
#include <delay.h>
#include <alcd.h>
#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;
}
/////////////////////
void H2BCD(int bil)
{
int rat,pul,sat;
rat=bil/100;
pul=(bil-(rat*100))/10;
sat=bil-(pul*10)-(rat*100);
lcd_putchar(rat+0x30);
lcd_putchar(pul+0x30);
lcd_putchar(sat+0x30);
}
void main(void)
{
int a;
PORTA=0x00;
DDRA=0xFF;
// ADC initialization
// ADC Clock frequency: 1000.000 kHz
// ADC Voltage Reference: AREF pin
// Only the 8 most significant bits of
// the AD conversion result are used
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x83;
lcd_init(16);
while (1)
{
a=read_adc(0);
lcd_gotoxy(0,0);
H2BCD(a);
}
}
Besaran
Analog
Besaran Digital
Desimal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
0V
0.05 V
0.1 V
0.2 V
0.3 V
0.4 V
0.5 V
0.6 V
0.7 V
0.8 V
0.9 V
1V
1.5 V
2V
2.5 V
3V
3.5 V
4V
4.5 V
5V
000
002
005
010
015
020
025
030
035
041
046
051
076
102
128
153
179
204
230
255
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
Kesimpulan
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________
_______________________________________________________________________