Tutorial Interface Microkontroller dengan Keypad menggunakan VMLAB

Berikut step by step tutorial interface microkontroller dengan keypad menggunakan VMLAB. Project ini menggunakan bahasa pemograman C dan menggunakan Microkontroller Atmega 16.

Petama buka lembar kerja baru VMLAB dengan mengklik 2 kali icon VMLAB

 
 Pada Lembar kerja VMLAB klik Project - New Project muncul gambar seperti berikut:

Isi step by step sampai seperti berikut :







Setelah terisi semua klik OK kemudian akan muncul seperti gambar berikut :



Kemudian pada jendela .prj masukkan kode berikut :

; ************************************************************
; PROJECT:
; AUTHOR:
; ************************************************************

; Micro + software running
; ------------------------------------------------------------
.MICRO "ATmega16"
.TOOLCHAIN "GCC"
.GCCPATH   "C:\WinAVR-20100110"
.GCCMAKE   AUTO
.TARGET    "dua.hex"
.SOURCE    "dua.c"

.TRACE              ; Activate micro trace

; Following lines are optional; if not included
; exactly these values are taken by default
; ------------------------------------------------------------
.POWER VDD=5 VSS=0  ; Power nodes
.CLOCK 1meg         ; Micro clock
.STORE 250m         ; Trace (micro+signals) storage time

; Micro nodes: RESET, AREF, PA0-PA7, PB0-PB7, PC0-PC7, PD0-PD7, ACO, TIM1OVF
; Define here the hardware around the micro
; ------------------------------------------------------------
D1 VDD PD0
D2 VDD PD1
D3 VDD PD2
D4 VDD PD3
D5 VDD PD4
D6 VDD PD5
D7 VDD PD6
D8 VDD PD7

K0 PC0 VSS
K1 PC1 VSS
K2 PC2 VSS
K3 PC3 VSS
K4 PC4 VSS
K5 PC5 VSS
K6 PC6 VSS
K7 PC7 VSS


Seperti gambar berikut :



Kemudian pada jendela .Hex masukkan kode berikut :

// ***********************************************************
// Project:
// Author:
// Module description:
// ***********************************************************

#include <avr\io.h>              // Most basic include files
#include <avr\interrupt.h>       // Add the necessary ones
#include <avr\signal.h>          // here

// Define here the global static variables
//
int My_global;

// Interrupt handler example for INT0
//
SIGNAL(SIG_INTERRUPT0) {

}

// It is recommended to use this coding style to
// follow better the mixed C-assembly code in the
// Program Memory window
//
void my_function(void) {  // Put the open brace '{' here

   asm("nop");          // Inline assembly example
}

// ***********************************************************
// Main program
//
int main(void) {
DDRD=0xff;
DDRC=0x00;
PORTC=0xff;
   while(1) {             // Infinite loop; define here the
      my_function();      // system behaviour
PORTD=PINC;
  }

}

Seperti gambar berikut :


Kemudian klik Project - Build (F9), muncul pada jendela massages "succsess! All ready to run" seperti gambar berikut :


Kemudian klik Run - Go/Continue, rangkain akan berjalan pada jendela Control Panel jika di klik tombol keypad maka led akan hidup sesuai tombol yang ditekan seperti gambar berikut :


   Selesai, sekian tutorial interface microkontroller dengan keypad menggunakan VMLAB.





1 comment: