Отправлено спустя 6 минут 4 секунды:
как я понимаю когда приходит единица на 2 пин то приходит оповещение с текстом "Yaaay... button is pressed!".
при создание блока в параметрах пользователя добавляю "Yaaay... button is pressed!" тип делаю string в loop вставляю строк: int isButtonPressed = !digitalRead(2);
if (isButtonPressed) {
Serial.println("Button is pressed.");
// Note:
// We allow 1 notification per 15 seconds for now.
Blynk.notify("Yaaay... button is pressed!");
а вот дальше не понимаю что делать.подключения через sim 900.
вот код из примера.
Код: Выделить всё
Download latest Blynk library here:
https://github.com/blynkkk/blynk-library/releases/latest
Blynk is a platform with iOS and Android apps to control
Arduino, Raspberry Pi and the likes over the Internet.
You can easily build graphic interfaces for all your
projects by simply dragging and dropping widgets.
Downloads, docs, tutorials: http://www.blynk.cc
Sketch generator: http://examples.blynk.cc
Blynk community: http://community.blynk.cc
Follow us: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
Attention! Please check out TinyGSM guide:
http://tiny.cc/tiny-gsm-readme
WARNING: GSM modem support is for BETA testing.
Simple push notification example
App project setup:
Push widget
Connect a button to pin 2 and GND...
Pressing this button will also push a message! ;)
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#define TINY_GSM_MODEM_SIM900
// Default heartbeat interval for GSM is 60
// If you want override this value, uncomment and set this option:
//#define BLYNK_HEARTBEAT 30
#include <TinyGsmClient.h>
#include <BlynkSimpleSIM800.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";
// Your GPRS credentials
// Leave empty, if missing user or pass
char apn[] = "YourAPN";
char user[] = "";
char pass[] = "";
// Hardware Serial on Mega, Leonardo, Micro
//#define SerialAT Serial1
// or Software Serial on Uno, Nano
#include <SoftwareSerial.h>
SoftwareSerial SerialAT(7, 8); // RX, TX
TinyGsm modem(SerialAT);
void notifyOnButtonPress()
{
// Invert state, since button is "Active LOW"
int isButtonPressed = !digitalRead(2);
if (isButtonPressed) {
Serial.println("Button is pressed.");
// Note:
// We allow 1 notification per 15 seconds for now.
Blynk.notify("Yaaay... button is pressed!");
}
}
void setup()
{
// Debug console
Serial.begin(9600);
delay(10);
// Set GSM module baud rate
SerialAT.begin(9600);
delay(3000);
// Restart takes quite some time
// To skip it, call init() instead of restart()
Serial.println("Initializing modem...");
modem.restart();
// Unlock your SIM card with a PIN
//modem.simUnlock("1234");
Blynk.begin(auth, modem, apn, user, pass);
// Setup notification button on pin 2
pinMode(2, INPUT_PULLUP);
// Attach pin 2 interrupt to our handler
attachInterrupt(digitalPinToInterrupt(2), notifyOnButtonPress, CHANGE);
}
void loop()
{
Blynk.run();
}