Hello all,
Newbie Warning
I am trying to use my Arduino nano + HC-05 to send a push notification to my android when I push a physical button, I have done a lot of trying to splice different codes together with zero luck, any guidance would be greatly appreciated.
#define BLYNK_PRINT Serial
#define BLYNK_USE_DIRECT_CONNECT
#include <SoftwareSerial.h>
SoftwareSerial DebugSerial(2, 3); // RX, TX
int button = 13;
#define BLYNK_PRINT DebugSerial
#include <BlynkSimpleSerialBLE.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(Serial, auth);
DebugSerial.begin(9600);
DebugSerial.println("Waiting for connections...");
// Setup notification button on pin 13
pinMode(13, INPUT_PULLUP);
// Attach pin 2 interrupt to our handler
attachInterrupt(digitalPinToInterrupt(13), notifyOnButtonPress, CHANGE);
}
void notifyOnButtonPress()
{
// Invert state, since button is "Active LOW"
if(digitalRead(button) == HIGH){
Serial.println("Button is pressed.");
// Note:
// We allow 1 notification per 15 seconds for now.
Blynk.notify("Yaaay... button is pressed!");
}
}
void loop()
{
if(digitalRead(button) == HIGH){
Serial.println("Button is pressed.");
// Note:
// We allow 1 notification per 15 seconds for now.
Blynk.notify("Yaaay... button is pressed!");
Blynk.run();
}
}