Leds on/off


Closed Thread
Results 1 to 17 of 17

Thread: Leds on/off

Hybrid View

  1. #1
    Join Date
    May 2007
    Location
    Republic Serbia
    Posts
    105


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi,

    I do not remember the 16F84 had an internal oscillator ...

    none aboard the ( censored ) simulation ...

    But I'm just getting 53 ...

    Alain

    PS: Ahhhhh ... Da Vinci Code !!!!
    16F84 and 16F84A do not have internal OSC...

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by phoenix_1 View Post
    16F84 and 16F84A do not have internal OSC...
    Quote Originally Posted by Acetronics View Post
    Hi,

    I do not remember the 16F84 had an internal oscillator ...

    none aboard the ( censored ) simulation ...

    But I'm just getting 53 ...

    Alain

    PS: Ahhhhh ... Da Vinci Code !!!!

    On his simulator, it is not required to connect crystal or resonator etc.
    It will run normally as if those were connected.

    ---------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi, Sayzer

    I do not want to use sims ... lol

    BTW :


    ...

    IF PORTB.0=0 then
    HIGH PORTB.4
    WHILE PORTB.0=0 : Wend : pause 50
    ENDIF

    IF PORTB.0=0 then
    LOW PORTB.4
    WHILE PORTB.0=0 : Wend : pause 50
    ENDIF

    ...
    This kind of structure can't work properly ... as the second part never can be reached !!! ( or toggling button in less than 1µs ... )

    Button state AND its corresponding output state must be tested at the same time ... to take the appropriate action.

    Alain
    Last edited by Acetronics2; - 29th August 2009 at 10:09.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Talking

    Sorry ...

    or toggling button in less than 1µs ...
    was not 1µs but 50 ms ...

    but result is the same !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    chatchai's Avatar
    chatchai Guest


    Did you find this post helpful? Yes | No

    Red face I am speek Thai and my english very bad... but my example..

    ' Test I/O Ports Input and Output

    SW1 var PORTB.0
    SW2 var PORTB.1
    SW3 var PORTB.2
    SW4 var PORTB.3

    LED1 VAR PORTD.0
    LED2 VAR PORTD.1
    LED3 VAR PORTD.2
    LED4 VAR PORTD.3

    i var byte

    DEFINE OSC 48


    '------- Initial IO Ports -------


    TRISB = $FF
    TRISD = 0

    CMCON = 0
    ADCON1 = 7

    '------- Main Function -------
    main:
    LED1 = SW1
    LED2 = SW2
    LED3 = SW3
    LED4 = SW4

    goto main

  6. #6
    Join Date
    Jan 2008
    Location
    Sweden
    Posts
    187


    Did you find this post helpful? Yes | No

    Default

    Try this

    Code:
    start:
    IF PORTB.0=0 then
        toggle PORTB.4
        WHILE PORTB.0=0 : Wend : pause 50
    ENDIF
        
        
    IF PORTB.1=0 then
        toggle PORTB.5
        WHILE PORTB.1=0 : Wend : pause 50
    ENDIF
            
    IF PORTB.2=0 then
        toggle PORTB.6
        WHILE PORTB.2=0 : Wend : pause 50
    ENDIF
            
    IF PORTB.3=0 then
        toggle PORTB.7
        WHILE PORTa.3=0 : Wend : pause 50
    ENDIF
        
          
    goto start

  7. #7
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Place a 330 ohms in series to each leds (as suggested in previuos post), and use Toggle command (as suggested in previuos post).

    Code:
    start:
    Pause 50
    IF PORTB.0=0 then
        Toggle PORTB.4       
        ENDIF
        
    IF PORTB.1=0 then
        Toggle PORTB.5     
        ENDIF
        
    IF PORTB.2=0 then
        Toggle PORTB.6     
         ENDIF
        
    IF PORTB.3=0 then
        Toggle PORTB.7    
         ENDIF
    
    HoldLoop:
    If PortB & %00001111 != 15 then HoldLoop
    
    goto start


    Al.
    Last edited by aratti; - 31st August 2009 at 12:25.
    All progress began with an idea

Similar Threads

  1. Run a string of LEDs from the mains
    By The Master in forum Off Topic
    Replies: 30
    Last Post: - 1st October 2009, 18:55
  2. Replies: 14
    Last Post: - 26th April 2007, 15:12
  3. Using LEDs as light sensors
    By skimask in forum Code Examples
    Replies: 3
    Last Post: - 30th December 2006, 22:19
  4. controlling leds with the switches
    By ilteris in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th October 2005, 21:02
  5. Replies: 5
    Last Post: - 16th February 2005, 11:57

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