JUL 6
Posted by pccontrol
Menggunakan Port Input dan Output Microcontroller
(h ps://pccontrol.les.wordpress.com/2011/07/inout-device.jpg)
1 of 7 05/04/2017 21:40
Dasar Pemrograman Input dan Output Microcontroller AVR dengan C C... https://pccontrol.wordpress.com/2011/07/06/dasar-pemrograman-input...
(h ps://pccontrol.les.wordpress.com/2011/07/io-avr.jpg)
Input Output Port
1. Set Port sebagai input diregister DDRx (ganti x dgn A,B,C atu D sesuai port yg akan di se ing)
2 of 7 05/04/2017 21:40
Dasar Pemrograman Input dan Output Microcontroller AVR dengan C C... https://pccontrol.wordpress.com/2011/07/06/dasar-pemrograman-input...
#include <mega8535.h>
void main(void)
{
// inisialisasi Port A sebagai output :
PORTA=0x00;
DDRA=0xFF;
// Inisialisasi Port C sebagai input :
PORTC=0x00;
DDRC=0x00;
while (1)
{
// tempatkan code yg akan kita buat disini
};
}
Contoh program PortC sbg Input dan
PortA sbg output
#include <mega8535.h>
Char inputdata;
Char outputdata;
void main(void)
{
// inisialisasi Port A sebagai output :
PORTA=0x00;
DDRA=0xFF;
// Inisialisasi Port C sebagai input :
PORTC=0x00;
DDRC=0x00;
while (1)
{
// tempatkan code yg akan kita buat disini
inputdata = PINC
outputdata = inputdata + 1;
PORTA = outputdata;
};
}
Pemrograman Input Output dengan codevision
1. Buka code vision
2. Buat Project baru
3. Pilih gunakan codewizard
3 of 7 05/04/2017 21:40
Dasar Pemrograman Input dan Output Microcontroller AVR dengan C C... https://pccontrol.wordpress.com/2011/07/06/dasar-pemrograman-input...
(h ps://pccontrol.les.wordpress.com/2011/07/io-wizard.jpg)
Codewizard
Untuk memilih kaki kaki PORTA sebagai input atau output , klik in atau out spt tampak pada gambar
diatas. Setelah itu klik le->Generate save and exit . setelah itu kita akan dibuatkan template program
sbb:
4 of 7 05/04/2017 21:40
Dasar Pemrograman Input dan Output Microcontroller AVR dengan C C... https://pccontrol.wordpress.com/2011/07/06/dasar-pemrograman-input...
#include <mega8535.h>
// Port C initialization
PORTC=0x00;
DDRC=0x00;
// Port D initialization
PORTD=0x00;
DDRD=0x00;
while (1)
{
// Place your code here
};
}
5 of 7 05/04/2017 21:40
Dasar Pemrograman Input dan Output Microcontroller AVR dengan C C... https://pccontrol.wordpress.com/2011/07/06/dasar-pemrograman-input...
About pccontrol
Berisi Tutorial Menggunakan PC untuk mengontrol Peralatan dengan cara mudah & praktis.
View all posts by pccontrol
Posted on 06/07/2011, in Menengah-1. Bookmark the permalink. Leave a comment.
Leave a comment
Comments 0
6 of 7 05/04/2017 21:40
Dasar Pemrograman Input dan Output Microcontroller AVR dengan C C... https://pccontrol.wordpress.com/2011/07/06/dasar-pemrograman-input...
Blog at WordPress.com.
7 of 7 05/04/2017 21:40