Forverse – Reverse Control For Basic PRO Compiler

@ device  PIC16F877 
define osc 4
define adc_bits 8
main:

    trisb =$00
    trisa =$ff
    adcon1 = 7
    sw1     var porta.0
    sw2     var porta.1 
    sw3     var porta.2           
    lamp1   var portb.0
    lamp2   var portb.1     
    lamp1=0 
    lamp2=0     

while(1)  
     if(!sw1 and sw2 and sw3) then 
       repeat    
        lamp1=1
        lamp2=0
        pause 10         
      until(!sw3):endif
     if(sw1 and !sw2 and sw3) then 
       repeat    
        lamp1=0
        lamp2=1
        pause 10         
      until(!sw3):endif  
     if(sw1 and sw2 and !sw3) then 
       repeat    
        lamp1=0
        lamp2=0
        pause 10         
      until(!sw1 or !sw2):endif        
wend 
end

About The Author

Ibrar Ayyub

I am an experienced technical writer with a Master's degree in computer science from BZU Multan University. I have written for various industries, mainly home automation, and engineering. I have a clear and simple writing style and am skilled in using infographics and diagrams. I am a great researcher and is able to present information in a well-organized and logical manner.

Follow Us:
LinkedinTwitter