Beranda > Elektronika > Making a LED Blink

Making a LED Blink

The first step is to build a simple circuit. At this point you should be familiar with the parts used. (1 resistors, and 1 LED). This design is intended for use with an Atmel 89s51 but also posible for others family 8051. Most microcontrollers can handle the current required to turn an LED on and off but. In this lesson we’re going to make a LED Blink continously.

led

Step 1st
Build the circuit as shown in figure 2.1.1 As you seen on figure 2.1.1 P0.0 is connected to LED’s katode. Remember, that all we want to do with this lesson is make a LED blink.

Step 2nd
In this step, you must tipe the assembly program to make the LED blink, we assume that you have already known the editor, we used MIDE-51 to edit the program.

       org 0h

start: Clr P0.0  ; send '0' to P0.0

       call delay; call delay time

       Setb P0.0 ; send '1' to P0.0

       call delay; call delay time

       sjmp start; loooooop forever to start

;=============================================

;subroutine delay created to rise delay time

;=============================================

delay: mov R1,#255

del1:  mov R2,#255

del2:  djnz R2,del2

       djnz R1,del1

       ret

end

Step 3rd
Safe your assembly program above, and name it with LED1.asm (for example) Compile the program that you have been save by using MIDE-51, see the software instruction.

Step 4th
Download your hex file ( LED1.hex ) into the microcontroller by using Microcontroller ATMEL ISP software, see the instruction.After download this hex file you’ll see the action of the LED ( of course if your cable connection and your program are corrected ).

Kategori:Elektronika
  1. din
    Mei 13, 2008 pukul 2:55 am

    contoh saya hasilkan…tp bagai mana kita nak set kan time daley setiap led…seperti led 1 akan myala selama 2 saat dan ikut seterusnya.

    $MOD51

    ORG 0H

    START: CLR P0.0
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY
    SETB P0.0
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY

    START1: CLR P0.1
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY
    SETB P0.1
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY

    START2: CLR P0.2
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY
    SETB P0.2
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY

    START3: CLR P0.3
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY
    SETB P0.3
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY

    START4: CLR P0.4
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY
    SETB P0.4
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY

    START5: CLR P0.5
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY
    SETB P0.5
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY

    START6: CLR P0.6
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY
    SETB P0.6
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY

    START7: CLR P0.7
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY
    SETB P0.7
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY

    START8: CLR P0.7
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY
    SETB P0.7
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY

    START9: CLR P0.6
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY
    SETB P0.6
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY

    START10:CLR P0.5
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY
    SETB P0.5
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY

    START11:CLR P0.4
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY
    SETB P0.4
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY

    START12:CLR P0.3
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY
    SETB P0.3
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY

    START13:CLR P0.2
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY
    SETB P0.2
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY

    START14:CLR P0.1
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY
    SETB P0.1
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY

    START15:CLR P0.0
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY
    SETB P0.0
    CALL DELAY
    CALL DELAY
    CALL DELAY
    CALL DELAY
    LJMP START

    DELAY: MOV R0,#00H
    LOP: MOV R1,#50
    LOP2: DJNZ R1,LOP2
    DJNZ R0,LOP
    RET

    END

  2. Juni 16, 2008 pukul 4:17 am

    ; ———————————————————
    ;;awak boleh pake listing ini…dicoba aja…ok
    ; ———————————————————
    $mod51
    Org 0h

    nop
    Mulai: Mov R2,#7
    Mov A,#11111110B ; Masukkan data 11111111B ke Accumulator
    Ulang1: Mov P1,A ; keluarkan isi Accumulator ke Port 1
    CLR C
    RLC A ; panggil sub routine Delay
    call Delay ; Rotate Accumulator left with carry
    DJNZ R2,ULANG1 ; ÚÄ<Ä b7Äb6Äb5Äb4Äb3Äb2Äb1Äb0 ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
    Ulang2: Mov P1,A ; keluarkan isi Accumulator ke Port 1
    setb C
    RRC A
    call Delay
    DJNZ R2,ULANG2
    mov P1,#0FFh
    call delay
    call delay
    call delay
    LED_kanan_kiri:
    clr P1.3
    clr P1.4
    call delay
    clr P1.2
    clr P1.5
    call delay
    clr P1.1
    clr P1.6
    call delay
    clr P1.0
    clr P1.7
    call delay
    call delay
    call delay
    setb P1.0
    setb P1.7
    call delay
    setb P1.1
    setb P1.6
    call delay
    setb P1.2
    setb P1.5
    call delay
    setb P1.3
    setb P1.4
    call delay
    call delay
    mov R4,#2
    LED_jalan_dua:
    Mov R2,#6
    Mov A,#11111100B ; Masukkan data 111111100B ke Accumulator
    loop1: Mov P1,A ; keluarkan isi Accumulator ke Port 1
    RL A ; panggil sub routine Delay
    call Delay ; Rotate Accumulator left with carry
    DJNZ R2,loop1 ; ÚÄ<Ä b7Äb6Äb5Äb4Äb3Äb2Äb1Äb0 ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ
    loop2: Mov P1,A ; keluarkan isi Accumulator ke Port 1
    RR A
    call Delay
    DJNZ R2,loop2
    djnz R4,LED_jalan_dua
    LED_jalan_satu_satu:
    mov dptr,#LED_satu
    mov R4,#36
    next1: clr A
    Movc A,@A+DPTR
    cpl A
    Mov P1,A
    inc dptr
    call Delay
    djnz R4,next1
    call delay
    call delay
    call delay
    mov dptr,#LED_satu
    mov R4,#36
    next2: mov A,R4
    Movc A,@A+DPTR
    cpl A
    Mov P1,A
    call Delay
    djnz R4,next2
    mov P1,#0FFh
    call delay
    call delay
    call delay
    jmp mulai
    ;——————-
    ; sub routine delay
    ;——————-
    Delay: DJNZ R3,delay ; R3=R3-1 bila 0 ke label delay
    Djnz R1,Delay ; R1=R1-1 bila 0 ke label delay
    Ret ; Kembali ke alamat setelah perintah
    ; ‘call Delay’
    LED_SATU:
    DB 01h,02H,04H,08H,10H,20H,40H,80H
    DB 81h,82h,84h,88h,90h,0B0h,0C0h
    DB 0C1h,0C2h,0C4h,0C8h,0D0h,0E0h
    DB 0E1h,0E2h,0E4h,0E8h,0F0h
    DB 0F1h,0F2h,0F4h,0F8h
    DB 0F9h,0FBh,0FCh
    DB 0FDH,0FEh
    DB 0FFh
    End

  3. karthik
    Oktober 10, 2008 pukul 3:25 am

    thank a lot

  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: