Hello all,
After a lot of Googling, I still can’t figure this out. I am working on a project where I want to have an automatic routine run while allowing for manual control through the Blynk app. I want to turn off the auto routine when manual mode is turned on through the app. Please take a look and let me know if you have a suggestion.
Thanks!
Hardware model + communication type: Arduino UNO with Ethernet 2 Shield
Android)
Blynk server
/*************************************************************
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
Social networks: http://www.fb.com/blynkapp
http://twitter.com/blynk_app
Blynk library is licensed under MIT license
This example code is in public domain.
*************************************************************
This example shows how to use Arduino Ethernet Shield 2 (W5500)
to connect your project to Blynk.
Note: This requires Ethernet2 library
from http://librarymanager/all#Ethernet2
Pins 10, 11, 12 and 13 are reserved for Ethernet module.
DON'T use them in your sketch directly!
Feel free to apply it to any other example. It's simple!
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <SimpleTimer.h>
#include <SPI.h>
#include <Ethernet2.h>
#include <BlynkSimpleEthernet2.h>
BlynkTimer timer;
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "**********************************iiV7";
int Blynk_controlU = 7; //Digital Pin 5 is for Blynk manual Mode "UP"
int Blynk_controlD = 8; //Digital Pin 8 is for Blynk manual Mode "Down"
int Blynk_controlMANUAL = 5; // Digital Pin 7 is for Blynk Manual Mode
int trigger = 3; //Digital Pin 3 is Trigger for manual mode
int Auto_ControlU = 6; //Digital Pin 6 is for Auto Control "UP"
int Auto_ControlD = 9; //Digital Pin 9 is for Auto Control "DOWN"
//////////////////////////////////////////////////////
void routine_manual()
{digitalWrite(Auto_ControlU, LOW);
digitalWrite(Auto_ControlD, LOW);}
//////////////////////////////////////////////////////
void routine_auto()
{digitalWrite(Auto_ControlU, HIGH);
delay(1000);
digitalWrite(Auto_ControlU, LOW);
delay(1000);
digitalWrite(Auto_ControlD, HIGH);
delay(1000);
digitalWrite(Auto_ControlD, LOW);
delay(1000);}
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
void setup()
{
pinMode(Blynk_controlU,OUTPUT);
pinMode(Blynk_controlD,OUTPUT);
pinMode(Blynk_controlMANUAL,OUTPUT);
pinMode(trigger,INPUT);
pinMode(Auto_ControlU,OUTPUT);
pinMode(Auto_ControlD,OUTPUT);
timer.setInterval(1000L,TimerEvent);
// Debug console
Serial.begin(9600);
Blynk.begin(auth);
// You can also specify server:
//Blynk.begin(auth, "blynk-cloud.com", 80);
//Blynk.begin(auth, IPAddress(192,168,1,100), 8080);
// For more options, see Boards_Ethernet/Arduino_Ethernet_Manual example
}
void TimerEvent(){
if (digitalRead(trigger == 1)){
routine_manual();
}else{
routine_auto();
}
Serial.println(digitalRead(trigger));
}
void loop()
{
Blynk.run();
timer.run();
}
//////////////////////////////////////////////////////