const int bpin = 15; //botao
const int LED = 4; //fechar
const int t; //variavel do impulso do comando
const int state_1 = 0; // Variável dos estados de abertura/fecho/paragem | Variable of States the open/close/stop
const int state_2 = 0; // Variável dos estados da luz intermitente | Variable of Blinking light state
// set pin numbers
//const int buttonPin = 4; // the number of the pushbutton pin
//const int ledPin = 5; // the number of the LED pin
// variable for storing the pushbutton status
int buttonState = 0;
void setup() {
Serial.begin(115200);
// initialize the pushbutton pin as an input
pinMode(bpin, INPUT);
// initialize the LED pin as an output
pinMode(LED, OUTPUT);
}
void pin_ISR() { //Rotina de Interrupção | Interrupt Service Routine.
t = digitalRead(bpin); // Leitura da Variavel T | Reading of Variable T.
state_1_next(); // Chamada da função FSM1 - estado seguinte | Calls function FSM1 - next state
state_1_out(); // Chamada da função FSM2 - saída do estado | Calls function FSM2 - output state
//digitalWrite (A, Abre); // Leitura da Variavel A. | Reading of Variable A
//digitalWrite (F, Fecha); // Leitura da Variavel F.
}
void state_1_next(){
switch (state_1){
case 0:
if (t==HIGH){
state_1=1;
}
break;
case 1:
if (t==LOW){
state_1=1;
}
break; }
}
void state_1_out(){
switch (state_1){
case 0:
LED=0;
break;
case 1:
LED=1;
break;
}
}