Skip to content

Instantly share code, notes, and snippets.

@gbrennon
Created October 25, 2021 03:54
Show Gist options
  • Save gbrennon/593b71f6c7840aa5b6006f098b3b0016 to your computer and use it in GitHub Desktop.
Save gbrennon/593b71f6c7840aa5b6006f098b3b0016 to your computer and use it in GitHub Desktop.
int but;
void main()
{
char x = 0;
int i=0;
bit Play;
bit LastStatusPlay;
bit LastStatusClear;
TRISA = 0x00; // set direction to be output
TRISB = 0xFF;
Play = 0;
LastStatusPlay = 0;
LastStatusClear = 0;
//PORTA = x;
//loop infinito!
while (1)
{
while(i < 10)
{
Delay_ms(100); // Faz 10x 100ms para testar os botões 10x num segundo
//Muda Status de Play na borda de subida
if ((LastStatusPlay==0) && (but==1)){
Play = !Play;
but=0;
}
LastStatusPlay = but;
//Conta parcelas de 100ms se em estado de Play. Caso contrário, guarda
//o tempo que ainda falta para completar 1s
if (Play) i++;
if (RB1_bit){
x=0;
i=0;
//PORTA = x;
//break;
}
// LastStatusClear = RB1_bit;
}
if (Play) x++;
PORTA = x;
}
}
void interrupt()
{
but++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment