Using Codewizard in CodevisionAVR
PROGRAM : OUTPUT
Tujuan Program : Membuat delapan lampu LED menyala
Hardware : Hubungkan rangkaian LED ke PORTC
Codewizard : setting PORTC sebagai output, set Chip
Langkahnya….
1. Pilih shortcut codevisionAVR dengan tampilan seperti berikut

2. Buat file baru dengan cara : File , NEW

3.Pilih Project

4. Pilih Codewizard

5. Menggunakan CodeWizard : Pengaturan Chip, jenis mikro dan nilai crystal yang digunakan

6.Menggunakan CodeWizard, setting PORTC sebagai Output (klik “In” shg berubah menjadi “out”)

7.Simpan hasil CodeWizard

8.Save setting : save tiga kali dengan nama file yang persis sama

…..SELESAI……

Nah, di program yang dah jadi ini tinggal menambahkan kebutuhan kita, contohnya saya mau menyalakan 8 buah LED (aktif high) yang terhubung di PORT C maka program tambahannya adalah

RELEASE …Guidline Project (REVISI)
it`s finish, if you want to have it, just click this link
Bagi yang ingin memperoleh e-book ini silahkan langsung download saja, sudah saya upload lewat scribd, download disini

Minimum Schematic for micro-controller
This is the minimum schematic for your microcon, if you want to use one of these pin I/O just put another jumper/pin header on the board.

to be continue….
ADC to LCD (ATmega8535)
as my promise to aryo danurwendo
Pertama codewizardnya di setting dulu yah, terutama adc dan lcd
This is the source code, enjoy
========================================================
#include mega8535.h
#include delay.h
// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0×15 ;PORTC
#endasm
#include lcd.h
#include stdio.h
#define ADC_VREF_TYPE 0×60
// 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|=0×40;
// Wait for the AD conversion to complete
while ((ADCSRA & 0×10)==0);
ADCSRA|=0×10;
return ADCH;
}
// Declare your global variables here
char lcd_buffer[33];
void main(void)
{
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0×80;
SFIOR=0×00;
// ADC initialization
// ADC Clock frequency: 691.200 kHz
// ADC Voltage Reference: AVCC pin
// ADC High Speed Mode: Off
// ADC Auto Trigger Source: Free Running
// Only the 8 most significant bits of
// the AD conversion result are used
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0xA4;
SFIOR&=0x0F;
// LCD module initialization
lcd_init(16);
while (1)
{
lcd_gotoxy(0,0);
sprintf(lcd_buffer,”adc = %c “,read_adc(0));
lcd_puts(lcd_buffer);
};
}
============================================================
ini menampilkan hasil pembacaan adc di PORTA.0 ke LCD yang dipasang di PORTC
kalau mau membaca ADC yang lain, misal PORTA.1 ganti read_adc(0) jadi read_adc(1)
NB:
1. perhatikan yang include, seharusnya da tanda kurung tapi dianggap sintak ni sama webna jdi sy hapus aja
2. ini basicnya, silahkan di modif, kalau mau tampil berupa nilai tegangan seperti multimeter lihat post menampilkan bilangan desimal ke LCD
-
Archives
- July 2010 (1)
- May 2010 (1)
- March 2010 (4)
- February 2010 (4)
- July 2009 (1)
- March 2009 (4)
- February 2009 (2)
-
Categories
-
RSS
Entries RSS
Comments RSS

