Program error?

Discussion in 'Homework Help' started by yasir_66, Feb 7, 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; delay_ms(100);
    19.        l1=0; delay_ms(100);
    20.        l2=1; delay_ms(100);
    21.        l2=0; delay_ms(100);
    22.        l3=1; delay_ms(100);
    23.        l3=0;
    24.      }
    25.    }
    26. }
    27.  
     
    Last edited by a moderator: Feb 7, 2012
  2. u-will-neva-no

    Member

    Mar 22, 2011
    230
    2
    I have never programmed in this before so my answer could be total garbage. for the conditional statement: if(s1 ==0), try and just put if(s1).

    The reason is because I had a similar issue when I programmed in AVR but this may not solve your solution.
     
Loading...