percobaan 1 modul 3




ON-OFF LED

1.HARDWARE [kembali]





2.RANGKAIAN SIMULASI [kembali]


3.FLOWCHART [kembali]


4.LISTING PROGRAM [kembali]

  #include<mega128.h>                                   // untuk mengaktifkan library atmega128
# include <delay.h>                                        // untuk mengaktifkan library delay
void main(void)                                                // Fungsi utama
{                                                                              // Kurung pembuka
PORTE=0x00;                                                     // Mendeklarasikan kondisi awal PORT E dalam keadaan mati
DDRE=0x00;                                                        // Mendeklarasikan PORT E sebagai input
PORTC=0x00;                                                     // PORTC kondisi awalnya dalam keadaan mati
DDRC=0xff;                                                         // PORTC merupakan OUTPUT
while(1)                                                               // Fungsi Perulangan
{
if (PINE.1 == 1)                                                  // Jika PINE.1 bernilai 1
{
PORTC=0x0f;                                                      // 4 led di PORTC hidup
delay_ms(100);                                                 //delay 100ms
}
Else                                                                        // Jika Tidak
{
PORTC=0x00;                                                     // led di PORTC mati
 }
if (PINE.2==1)                                                    // Jika PINE.2 bernilai 1
{           
PORTC=0xf0;                                                      // Maka 4 led di PORTC akan hidup
delay_ms(100);                                                 // delay 100 ms
}
Else                                                                        // jika tidak
{
PORTC=0x00;                                                     // led di PORTC akan mati
delay_ms(100);                                                 // delay 100ms
} } }                                                                         //Kurung penutup

5.VIDEO [kembali]


6.LINK DOWNLOAD [kembali]

video
download

Tidak ada komentar:

Posting Komentar