LED timing


Results 1 to 6 of 6

Thread: LED timing

Threaded View

  1. #6
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Here, I think, what is needed.

    Code:
    <font color="#0000FF"><i>'All the usual stuff here.
    '....
    '....
    '....
    
    </i></font><b>Sw  </b><font color="#000080"><b>VAR </b></font><b>PORTA.</b><font color="#FF0000"><b>0 </b></font><font color="#0000FF"><i>' Switch is connected to RA0.
    </i></font><b>LED </b><font color="#000080"><b>VAR </b></font><b>PORTB.</b><font color="#FF0000"><b>0 </b></font><font color="#0000FF"><i>' LED is connected to RB0. 
    </i></font><b>Flag </b><font color="#000080"><b>VAR BIT    </b></font><font color="#0000FF"><i>' Use a flag to have a virtual falling-edge,rising-edge thingie.
    
    </i></font><b>Begin:
        </b><font color="#000080"><b>INPUT </b></font><b>Sw    </b><font color="#0000FF"><i>' Switch pin is an input pin. Tie it to V+ with a resistor.
        </i></font><b>Flag = </b><font color="#FF0000"><b>0
    
    </b></font><b>Loop:
    
    </b><font color="#0000FF"><i>' When button is pressed, the LED turns ON, stays ON 5 secs and then turns OFF.
    ' While button is being pressed, the led does NOT repeat Turn ON action. 
    ' When the button is released then Flag is cleared. Thus, what happens?
    
        </i></font><font color="#000080"><b>IF </b></font><b>Sw = </b><font color="#FF0000"><b>0 </b></font><font color="#000080"><b>AND </b></font><b>Flag = </b><font color="#FF0000"><b>0 </b></font><font color="#000080"><b>THEN </b></font><b>LedOn      </b><font color="#0000FF"><i>' SW is pressed.
    
        </i></font><font color="#000080"><b>IF </b></font><b>Sw = </b><font color="#FF0000"><b>1 </b></font><font color="#000080"><b>AND </b></font><b>Flag = </b><font color="#FF0000"><b>1 </b></font><font color="#000080"><b>THEN </b></font><b>Flag = </b><font color="#FF0000"><b>0   </b></font><font color="#0000FF"><i>' SW is released. 
    
    
    </i></font><font color="#000080"><b>GOTO </b></font><b>Loop
    
    
    
    LedOn:
    
        LED = </b><font color="#FF0000"><b>1     </b></font><font color="#0000FF"><i>' Turn ON led.
        </i></font><font color="#000080"><b>PAUSE </b></font><font color="#FF0000"><b>5000  </b></font><font color="#0000FF"><i>' Wait 5 secs.
        </i></font><b>LED = </b><font color="#FF0000"><b>0     </b></font><font color="#0000FF"><i>' Turn OFF Led.
    
        </i></font><b>Flag = </b><font color="#FF0000"><b>1 
    
        </b></font><font color="#000080"><b>GOTO </b></font><b>Loop
    
    </b><font color="#000080"><b>END
    
    </b></font>
    Last edited by sayzer; - 28th June 2008 at 10:59. Reason: typo
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. Conway's Game Of Life
    By wellyboot in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 28th May 2020, 06:14
  2. new and need help
    By smeghead in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd November 2008, 20:19
  3. For next loop using: Led var Byte
    By quester in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th March 2008, 10:16
  4. LCD will not start
    By btaylor in forum mel PIC BASIC Pro
    Replies: 49
    Last Post: - 24th May 2007, 02:30
  5. can't even flash an LED
    By bruno333 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 28th April 2005, 13:27

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts