what's wrong with code?

Discussion in 'Homework Help' started by yasir_66, Feb 3, 2012.

  1. yasir_66

    Thread Starter Active Member

    Jun 25, 2009
    71
    1
    hello friends,

    i built a program on pcwhd ccs compiler for simple three leds.After checking the program on Proteus 7.4 sp3 the problem is that i programmed it such that if i press push button(s1==) then led should turn on but on proteus 7.4 pro the leds are working without pressing push button

    here is code;

    Code ( (Unknown Language)):
    1.  
    2. #include<16f877A.h>
    3. #fuses NOWDT,HS,NOLVP,NOPROTECT
    4. #use delay(clock=20Mhz)
    5. #bit l1=5.0
    6. #bit l2=5.1
    7. #bit l3=5.2
    8. #bit s1=6.0
    9. main()
    10. {
    11. set_tris_a(0b000000);
    12. set_tris_b(0b11111111);
    13. l1=l2=l3=0;
    14. while(1)
    15. {
    16. if(s1==0)
    17. {
    18. l1=1;
    19. delay_ms(100);
    20. l1=0;
    21. delay_ms(100);
    22. l2=1;
    23. delay_ms(100);
    24. l2=0;
    25. delay_ms(100);
    26. l3=1;
    27. delay_ms(100);
    28. l3=0;
    29. }
    30. }
    31. }
    32.  
     
    Last edited: Feb 3, 2012
Loading...