Jumat, Juli 04, 2014

Membuat Running LED (Seri Tutorial Micro controller)

Kali ini saya mencoba untuk menulis tutorial tentang Micro Controller menggunakan seri ATMega8535, memanfaatkan lampu LED yang menghasilkan tampilan nyala LED yang berurutan serta secara acak.
Siapkan komponen-komponenya sebagai berikut :
Micro Controller seri ATMega8535      1x
Switch / Saklar push button no/nc         1x
Crystal 12 MHz                                     1x
Capasitor 33pF                                      2x
PCB atau Project Board/Breadboard    1x

Software yang digunakan :
ISIS Proteus yang digunakan untuk membuat rangkaian simulasi.
BASCOM AVR : software bahasa pemrograman untuk membuat program gerakan LED.

Langkah pertama yaitu anda ketik lebih dahulu listing programnya seperti contoh di bawah ini

'Project          : Running LED Random
'Author           : Hasmi Susanto, ST.
'Date             : July, 4 2014

$regfile = "m8535.dat"                                      'registrasi MiCon ATMega8535
$crystal = 11059200                                         'registrasi Crystal yang dipakai
Config Portb = Input                                        'konfigurasi Port B sebagai Input
Config Porta = Output                                       'konfigurasi Port A sebagai Output
Config Portc = Output                                       'konfigurasi Port C sebagai Output
Sw1 Alias Portb.1                                           'saklar disambung ke Port B no 1
Led Alias Portc                                             'semua LED disambung ke Port C

Ddrb = &B00000000                                           'LED OFF semua
Portc = &B11111111                                          'Semua LED dinyalakan
'--------------------------------
Do
   If Sw1 = 0 Then                                          'Switch OFF
      Waitms 50                                             'Delay 50 mili detik
      Led = &B00000000
      Waitms 20
      Led = &B11111111
      Waitms 50
      Led = &B00000000
      Waitms 20
      Led = &B11111111
      Waitms 50
      Led = &B00000000
      Waitms 20
      Led = &B11111111
      Waitms 50
      Led = &B00000000
      Waitms 20
      Led = &B11111111
      Waitms 50
'---------------- Mode LED ke 2 ------------------
      Led = &B11111110
      Waitms 10
      Led = &B11111101
      Waitms 10
      Led = &B11111011
      Waitms 10
      Led = &B11110111
      Waitms 10
      Led = &B11101111
      Waitms 10
      Led = &B11011111
      Waitms 10
      Led = &B10111111
      Waitms 10
      Led = &B01111111
'--------------- Mode LED ke 3--------------------- 1
      Waitms 10
      Led = &B01111110
      Waitms 10
      Led = &B01111101
      Waitms 10
      Led = &B01111011
      Waitms 10
      Led = &B01110111
      Waitms 10
      Led = &B01101111
      Waitms 10
      Led = &B01011111
      Waitms 10
      Led = &B00111111
'--------------- Mode LED ke 4 --------------- 2
      Waitms 10
      Led = &B00111110
      Waitms 10
      Led = &B00111101
      Waitms 10
      Led = &B00111011
      Waitms 10
      Led = &B00110111
      Waitms 10
      Led = &B00101111
      Waitms 10
      Led = &B00011111
'------------------------------- 3
      Waitms 10
      Led = &B00011110
      Waitms 10
      Led = &B00011101
      Waitms 10
      Led = &B00011011
      Waitms 10
      Led = &B00010111
      Waitms 10
      Led = &B00001111
'----------------------------------- 4
      Waitms 10
      Led = &B00001110
      Waitms 10
      Led = &B00001101
      Waitms 10
      Led = &B00001011
      Waitms 10
      Led = &B00000111
'---------------------------------- 5
      Waitms 10
      Led = &B00000110
      Waitms 10
      Led = &B00000101
      Waitms 10
      Led = &B00000011
'---------------------------------- 6
      Waitms 10
      Led = &B00000010
      Waitms 10
      Led = &B00000000
'--------------------------------- 7
      Waitms 30
      Led = &B11100111
      Waitms 10
      Led = &B11000011
      Waitms 10
      Led = &B10000001
      Waitms 10
      Led = &B00000000
      Waitms 10
      Led = &B10000001
      Waitms 10
      Led = &B11000011
      Waitms 10
      Led = &B11100111
      Waitms 10
      Led = &B11111111
'---------------------------------
      Waitms 30
      Led = &B11100111
      Waitms 10
      Led = &B11000011
      Waitms 10
      Led = &B10000001
      Waitms 10
      Led = &B00000000
      Waitms 10
      Led = &B10000001
      Waitms 10
      Led = &B11000011
      Waitms 10
      Led = &B11100111
      Waitms 10
      Led = &B11111111
'--------------------------------
      Waitms 30
      Led = &B11100111
      Waitms 10
      Led = &B11000011
      Waitms 10
      Led = &B10000001
      Waitms 10
      Led = &B00000000
      Waitms 10
      Led = &B10000001
      Waitms 10
      Led = &B11000011
      Waitms 10
      Led = &B11100111
      Waitms 10
      Led = &B11111111
   End If
Loop

Gambar berikut adalah Rangkaian/Skema yang dibuat menggunakan ISIS PROTEUS
Hasilnya bisa anda lihat simulasi nya pada Video di bawah ini :



Semoga berhasil membuat rangkaian Running LED ini.


Tidak ada komentar:

Posting Komentar

Mohon beri komentar yaa...