led blink program pic16f72

Status
Not open for further replies.

sahu

Advanced Member level 2
Joined
Oct 9, 2009
Messages
516
Helped
68
Reputation
130
Reaction score
62
Trophy points
1,308
Location
Uttar pradesh (INDIA)
Activity points
3,876
I have to make a very simple program for led blinking .
Using buttons 1 and 6 lead me.When the button is pressed for a small time , then Led 1 should
be blinking.
This code is part 2 of the LED blink.
part 1- Lead 5 & 6
part 2- LED 1,2,3 & 4 blinking with batton scan
As long as the button is not pressed until the LED blinks 5-6

But when the button is pressed more then 2 sec & unpressed,led1 blink 12sec . ofter 12 sec part
1 agen run.
But when the button is agen pressed more then 10 sec & unpressed during 12 sec of led1 blinking
.led 1 off & led2 blinking 15 sec ,
But when the button is agen pressed more then 2 sec & unpressed,during 15 sec led3 blink & led2 off.
But when the button is agen pressed more then 2 sec & unpressed,during 15 sec led4 blink & led3 off.
now when the button is agen pressed more then 2 sec & unpressed part 1 agen run.
i has try but not get sessss
PHP:
if(RA4 ==0)
     {  led1 = 1;
     led2 = 0;
     led3 = 0;
       led4=0;
   //   tcnt++;
     
   tcnt=tcnt+1;
   
   if(tcnt == 2)
   {   sp++;
     if(sp>=1 )
      {  led1 = 0;
     led2 = 1;
     led3 = 0;
       led4=0;
     //tcnt=tcnt+1;
     }
   
if(sp==3 )  {led1 = 0;
     led2 = 0;
     led3 = 1;
       led4=0;
     //tcnt=tcnt+1;
   }
   tcnt =0;sp=0;
     }


if(RA4 =1)
     {                     led5=~led5;
led6=~led6;}
 

provide your circuit and your logic clearly. Have you pulled up to RA4? If it's not pull-up your led will on one by one without push your button.
 

Code:
if(RA4 =1)
     {                     led5=~led5;
led6=~led6;}

RA4=1 will assign the value 1 to RA4 not compare RA4 with 1.
This must be if(RA4==1)

Code:
if(RA4 ==0)
     {  
       led1 = 1;
       led2 = 0;
       led3 = 0;
       led4=0;
    
       tcnt=tcnt+1;
   
       if(tcnt == 2)
       {   
         sp++;
         if(sp>=1 )
         {  
           led1 = 0;
           led2 = 1;
           led3 = 0;
           led4=0;
         }
   
        if(sp==3 )  
       {
         led1 = 0;
         led2 = 0;
         led3 = 1;
         led4=0;
         //tcnt=tcnt+1;
       }
       tcnt =0;sp=0;
     }


     if(RA4 =1)
     {                     
       led5=~led5;
       led6=~led6;
     }
Problem with your parenthesis.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…