1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

PIC16F877, sample coding regarding the use of switch

  1. Aug 22, 2009 #1
    1. The problem statement, all variables and given/known data

    I'm learning PIC recently. Below is the coding that i have prepared and the attachment is the connection that I used. My question is, why the 2 LEDs will on immediately once i trigger the PIC? This is because the result is not something that should be coming out. What's wrong with my connection or my coding?

    Below is the coding part:
    define osc 8
    TRISA.0 = 1
    TRISA.1 = 1
    TRISD.0 = 0
    TRISD.1 = 0

    L1 var portd.0
    L2 var portd.1
    s1 var porta.0
    s2 var porta.1

    Main
    portd = 0
    if s1 = 0 then
    L1 = 1
    else
    L1 = 0
    endif
    if s2 = 0 then
    L2 = 1
    else
    L2 = 0
    endif
    pause 500
    goto Main
    end
    2. Relevant equations



    3. The attempt at a solution
     

    Attached Files:

  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: PIC16F877, sample coding regarding the use of switch
Loading...