Sabtu, 01 Desember 2012

Pemrograman ATmega8535 Dengan CodeVision AVR Part 1

Berhubung saya juga masih dalam tahap belajar dalam pemrograman mikrokontroller tipe ini maka tidak ada salahnya jika kita belajar bersama. Mungkin komentar dan saran dari teman2 bisa membantu saya dalam mempelajari pemrograman ATmega ini serta meningkatkan kualitas pemrograman saya khususnya.hehehehe
            Pada postingan pertama tentang Pemograman ATmega8535 Dengan CodeVision AVR  ini saya mencoba membuat program dengan modul outputnya berupa LED….(dari dasar dulu yang gan, maklum anak baru…hehehe). Pada aplikasi ini ane setting PortA sebagai output ke modul dan rangkaian lednya saya buat tipe low (akan menyala jika output IC dikasih logika 0). Untuk cara setting pada codevision bisa googling sendiri,,,maaf g saya posting. Ok langsung aja ke KTP…….eh kliru TKP (kaya OVJ aja..hehehe) cekibrot. ni listing progam yang ane buat :

Aplikasi Led Berkedip

/*****************************************************
This program was produced by the
CodeWizardAVR V2.05.0 Evaluation
Automatic Program Generator
© Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project : led kedip
Version :
Date    : 12/8/2011
Author  : Freeware, for evaluation and non-commercial use only
Company : fuad-07.blogspot.com
Comments:


Chip type               : ATmega8535
Program type            : Application
AVR Core Clock frequency: 8.000000 MHz
Memory model            : Small
External RAM size       : 0
Data Stack size         : 128
*****************************************************/

#include
#include

// Declare your global variables here

void main(void)
{
// Declare your local variables here


      . . . . . . . . . . . . . . . .
      Source code yang dihasilkan dari setting CodeVision AVR
      . . . . . . . . . . . . . . . .

while (1)
      {
      // Place your code here
        PORTA=0x00;
        delay_ms(100);
        PORTA=0xFF;
        delay_ms(100);
      }
}

Aplikasi Led Geser Kanan

/*****************************************************
This program was produced by the
CodeWizardAVR V2.05.0 Evaluation
Automatic Program Generator
© Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project : led geser kanan
Version :
Date    : 12/8/2011
Author  : Freeware, for evaluation and non-commercial use only
Company : fuad-07.blogspot.com
Comments:


Chip type               : ATmega8535
Program type            : Application
AVR Core Clock frequency: 8.000000 MHz
Memory model            : Small
External RAM size       : 0
Data Stack size         : 128
*****************************************************/

#include
#include

// Declare your global variables here

void main(void)
{
// Declare your local variables here

      . . . . . . . . . . . . . . . .
      Source code yang dihasilkan dari setting CodeVision AVR
      . . . . . . . . . . . . . . . .

while (1)
      {
      // Place your code here       
      PORTA=0xFE;
      delay_ms(100);
      PORTA=0xFD;
      delay_ms(100);
      PORTA=0xFB;
      delay_ms(100);
      PORTA=0xF7;
      delay_ms(100);
      PORTA=0xEF;
      delay_ms(100);
      PORTA=0xDF;
      delay_ms(100);
      PORTA=0xBF;
      delay_ms(100);
      PORTA=0x7F;
      delay_ms(100);
      }
}

Aplikasi Led Geser Kiri

/*****************************************************
This program was produced by the
CodeWizardAVR V2.05.0 Evaluation
Automatic Program Generator
© Copyright 1998-2010 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com

Project : led geser kiri
Version :
Date    : 12/8/2011
Author  : Freeware, for evaluation and non-commercial use only
Company : fuad=07.blogspot.com
Comments:


Chip type               : ATmega8535
Program type            : Application
AVR Core Clock frequency: 8.000000 MHz
Memory model            : Small
External RAM size       : 0
Data Stack size         : 128
*****************************************************/

#include
#include

// Declare your global variables here

void main(void)
{
      . . . . . . . . . . . . . . . .
      Source code yang dihasilkan dari setting CodeVision AVR
      . . . . . . . . . . . . . . . .
while (1)
      {
      // Place your code here       
      PORTA=0x7F;
      delay_ms(100);
      PORTA=0xBF;
      delay_ms(100);
      PORTA=0xDF;
      delay_ms(100);
      PORTA=0xEF;
      delay_ms(100);
      PORTA=0xF7;
      delay_ms(100);
      PORTA=0xFB;
      delay_ms(100);
      PORTA=0xFD;
      delay_ms(100);
      PORTA=0xFE;
      delay_ms(100);
      }
}

NB: untuk include-nya gak bisa nampil di postingan ni includenya mega8535.h baris pertama dan yang kedua delay.h

Silahkan dicoba gan, maaf kalo ada salah baru pemula….hehehehe…Komentar yang membangun sangat saya harapkan supaya saya yang katrok ini bisa berkembang….hehehehehehe
Ok silahkan dibaca dan silahkan di coba…terima kasih!!!!
MARI BELAJAR…………………………………………………………………………….

1 komentar:

  1. sangat bermanfaat mas. terutama untuk saya yg masi awam dengan mikrokontroller. terimakasih

    BalasHapus