#include "bluetooth.h" #include "string.h" #ifndef LED_H #include "led.h" #define LED_H #endif #define BUTTON D2 #define IR D5 int button_state = HIGH; void setup() { // put your setup code here, to run once: Serial.begin(9600); pinMode(IR, OUTPUT); digitalWrite(IR, HIGH); bluetooth_setup(); led_setup(); pinMode(BUTTON, INPUT_PULLUP); } void loop() { // put your main code here, to run repeatedly: int val = digitalRead(BUTTON); if (val == LOW && button_state == HIGH) { Serial.println("pressed"); send_bluetooth("on"); button_state = LOW; digitalWrite(CATHODE, HIGH); } else if (val == HIGH && button_state == LOW) { Serial.println("released"); send_bluetooth("off"); button_state = HIGH; digitalWrite(CATHODE, LOW); } delay(50); check_bluetooth_connection(); }