Você está na página 1de 2

#include <Arduino.

h>

/*

OBSERVAES

Cada cadeia de teste modifica o estado lgico


de uma LED, baseado nos estados dos botes.

*/

void botoes ()

//FUNO BOTOES

{
flipflop(botao1,led1);
flipflop(botao2,led2);
flipflop(botao3,led3);
flipflop(botao4,led4);
flipflop(botao5,led5);

if(digitalRead(botaoSer)==LOW && testeSer){


portao(estado);
estado=!estado;
testeSer=false;
}
if(digitalRead(botaoSer)==HIGH){
testeSer=true;
}

/* funo responsavel pra nao ter que usar o


delay e poder apertar mais de um interrruptor */

unsigned long LEDpreviousMillis = 0;


void flipflop(int portaent,int portasaida){
if (digitalRead(portaent) == LOW){
unsigned long LEDcurrentMillis = millis();
if ((LEDcurrentMillis - LEDpreviousMillis >= 300) &&
(digitalRead(portaent) == HIGH)){
digitalWrite(portasaida,!digitalRead(portasaida));
LEDpreviousMillis = LEDcurrentMillis;
}
}
}

Você também pode gostar