/*bool state = LOW;
const int led = 23, boton =33;
void led_togle(){
state = !state;
digitalWrite(led, state);
Serial.println("Se preciono");
while(!digitalRead(boton));
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(boton, INPUT_PULLUP);
pinMode(led, OUTPUT);
digitalWrite(led, state);
attachInterrupt(boton,led_togle,FALLING);
}
void loop() {
delay(1000); // this speeds up the simulation
}
*/
#include "InterCom.h"
const int led = 23, boton =33;
bool state = LOW,blink_en = false;
void led_togle(){
tougle();
//Serial.println("Se preciono");
while(!digitalRead(boton));
}
void tougle(void){
state = !state;
digitalWrite(led,state);
}
void blink_enable(void){
blink_en = !blink_en;
}
unsigned long last_t;
SimpleComand terminal;
float dato;
void test(void){
terminal.list();
}
void setup() {
pinMode(boton, INPUT_PULLUP);
pinMode(led, OUTPUT);
digitalWrite(led, state);
attachInterrupt(boton,led_togle,FALLING);
terminal.begin(115200);
terminal.enable_echo(true);
terminal.addComand("T",&dato);
terminal.addComand("pos",&dato);
terminal.addComand("led",led_togle);
terminal.addComand("list",test);
terminal.addComand("blink",blink_enable);
last_t= millis();
}
void loop() {
terminal.lisent();
/*
if((millis()-last_time)>= 500){
Serial.print("valor de dato =");
Serial.println(dato);
last_time = millis();
}
*/
if(blink_en && (millis()-last_t)>= 500){
last_t = millis();
tougle();
}
}