Ir ao conteúdo
  • Cadastre-se

Pic travando


Posts recomendados

boa tarde

 

criei o programa para um projeto e este esta travando depois de um certo tempo teria como dar uma luz , não sei se esta certo a maneira de programar 

então se alguém tiver uma sugestão agradeço 

 

#include <16f876a.h>

 

#FUSES NOWDT                    

#FUSES HS                       

#FUSES NOPUT                   

#FUSES PROTECT                  

#FUSES NODEBUG                  

#FUSES BROWNOUT               

#FUSES LVP                      

#FUSES NOCPD                    

#FUSES NOWRT                    

#use delay(clock=8192000)

 

 

 

#define SENSE     pin_a1

#define ON        pin_a2

#define HELP      pin_a3

 

 

#define SEPARADOR pin_c1

#define EMPURRA   pin_c2

#define APERTA    pin_c3

#define CONTATORA pin_c4

 

////////////////////////////////////////

int PULSE=0,PULSE_V=0,STATE_P=0,STATE_H=0,INIT=0,SEP_ON=0,PULSE1=0,PULSE_V1=0;

 

void main ()

{  

   

   while(1)

   { 

     

     PULSE=INPUT(ON);

     IF(PULSE==0 && PULSE_V==0)

          PULSE_V=1;

     IF(PULSE==1 && PULSE_V==1)

        { 

        delay_ms(500);

        STATE_P++;

        PULSE_V=0;

        SEP_ON=0;

        if(STATE_P>=2)

        {

        STATE_P=0;

        }

        }

     /* tratamento botao liga desliga */    

  ///////////////////////////////////////////////////////////////////////////   

   IF(!input(HELP))

         {

            delay_ms(200);

            STATE_H=1;

            STATE_P=0;

            SEP_ON=0;

         }

         ELSE STATE_H=1;

  ///////////////////////////////////////////////////////////////////////////      

   IF(STATE_P==1 && STATE_H==1 )

        {            

           output_high(CONTATORA);                       

 ////////////////////////////////////////////////////////////////////////////          

           INIT=1;

            PULSE1=INPUT(SENSE);

            IF(PULSE1==0 && PULSE_V1==0)

            PULSE_V1=1;

            IF(PULSE1==1 && PULSE_V1==1 && INIT==1)

            {  

            Output_high(SEPARADOR);

            output_high(EMPURRA);

            delay_ms(35);

            Output_high(APERTA);

            delay_ms(1200);

            output_low(APERTA);

            output_low(EMPURRA);

            output_low(SEPARADOR);

            PULSE_V1=0;

            }

           INIT=0;

 

        }//programa principal

    IF(STATE_P==0 && STATE_H==1)

         {

           output_low(CONTATORA);

           output_low(APERTA);

           output_low(EMPURRA);

           }//Desliga tudo

 

   }

}

Link para o comentário
Compartilhar em outros sites

  • 2 semanas depois...
Visitante
Este tópico está impedido de receber novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...