Connect with us

blink led

Discussion in 'Microcontrollers, Programming and IoT' started by vead, Sep 17, 2014.

Scroll to continue with content
  1. vead

    vead

    473
    14
    Nov 27, 2011
    I want to blink led for some time
    I made diagram using proteus
    component
    AT89C51
    crystal
    LED

    diagram

    assembly code

    Code:
           org 00h
        
          Setb P1.0          ; Led on
          clr   P1.0           ; Led off
         
           delay:
        mov    R1, #20
        mov    R2, #0
    delay1:    djnz    R2, delay1
        djnz    R1, delay1
      
       ret
       end  
    Q but Led is not blinking ?
     
  2. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Hardware errors:
    1. C3 should be higher than 1 nF. I suggest 100 nF.
    2. Add a pulldown resistor of around 10k from pin 9 to 0V.
    3. R2 must connect to VCC, not 0V.
    4. R2 must be a lot lower than 500k. For example try 470Ω.
    Firmware errors:
    1. You need to insert delays between the instructions that change the LED state.
    2. You need to make the LED state logic into a continuous loop, using a label at the start and an RJMP at the end.
    Code:
            ORG     0
    
    MainLoop:
            setb    P1.0                    ; Turn LED ON
            rcall   Delay                   ; Wait a short time
            clr     P1.0                    ; Turn LED OFF
            rcall   Delay                   ; Wait a short time
            rjmp    MainLoop                ; Loop forever
    
    Delay:
            mov     R1,#20                  ; Set up outer loop count
            mov     R2,#0                   ; Set up inner loop count
    Delay1: djnz    R2,Delay1               ; Inner loop
            djnz    R1,Delay1               ; Outer loop
            ret
    
            end
     
    vead and Harald Kapp like this.
  3. vead

    vead

    473
    14
    Nov 27, 2011
    you mean this type
     
  4. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    You've removed the pushbutton, and C3, and the connection to pin 31. Put those all back like in your diagram in post #1. You don't need R1 though. Actually I think R1 was supposed to be connected to pin 9 but you connected it to pin 31 instead.
     
    vead likes this.
  5. vead

    vead

    473
    14
    Nov 27, 2011
    now the led is blinking for very short time
    thank you very much for your help
     
  6. KrisBlueNZ

    KrisBlueNZ Sadly passed away in 2015

    8,393
    1,271
    Nov 28, 2011
    Your schematic is still wrong. Here's exactly how it should look.

    upload_2014-9-17_23-58-43.png
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
Loading...
Electronics Point Logo
Continue to site
Quote of the day

-