#include <SimpleTimer.h>
/**************************************************************
* 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
* 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 ESP8266 Shield (with AT commands)
* to connect your project to Blynk.
*
* WARNING!
* It's rather tricky to get it working, please read this article:
* https://github.com/blynkkk/blynk-library/wiki/ESP8266-with-AT-firmware
*
* Change WiFi ssid, pass, and Blynk auth token to run :)
* Feel free to apply it to any other example. It's simple!
*
**************************************************************/
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include<Servo.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "auth";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Dreamerz";
char pass[] = "pass";
// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial
Servo servo;
SimpleTimer timer;
// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
BLYNK_WRITE(V1) {
if ( param.asInt()== 1 ) {
void enable(timer);
digitalWrite(18, HIGH);
servo.write(255);
??? //replace this with a function that can execute the following after 2 seconds
digitalWrite(18, LOW);
}
}
BLYNK_WRITE(V1)
{ if ( param.asInt() == 0 ) {
void enable(timer);
digitalWrite(18, HIGH);
servo.write(10);
??? //replace this with a function that can execute the following after 2 seconds
digitalWrite(18, LOW);
}
}
void setup()
{
pinMode(18,OUTPUT);
timer.setTimeout(2000, repeatMe);
// Set console baud rate
Serial.begin(9600);
delay(10);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
}
void loop(){
timer.run();
Blynk.run();
help please. not able to understand simple timer @Costas@Jamin
You ask a question once. If someone does not reply, do not make more threads about the same question.
I would like to point out that it is a public holiday long weekend here in New Zealand. Itās summer and im going to the beach.
Here is your answer, it compiles but untested. Im not going to be around for 24 hours to help but someone else here might.
#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <Servo.h>
#include <SimpleTimer.h>
char auth[] = "auth";
char ssid[] = "Dreamerz";
char pass[] = "pass";
#define EspSerial Serial
Servo servo;
SimpleTimer timer;
#define ESP8266_BAUD 9600
ESP8266 wifi(&EspSerial);
// THIS IS A FUNCTION WHICH YOU CAN PASS AND
// ARGUMENT TO, AND CAN BE USED LOADS OF TIMES
// QUICKLY AND EASILY. YOU SHOULD ALWAYS BUILD
// FUNCTIONS TO DO REPEATED TASKS
void servo_ON(int data) {
digitalWrite(18, HIGH);
delay(10); // NO MORE THAN 25ms is OKAY
servo.write(data); // PASSING data TO THE servo.write() COMMAND
}
// THE SIMPLE OFF FUNCTION. THIS ONE CANT HAVE AN ARGUMENT
// BECAUSE IT IS A CALLBACK FOR THE TIMER. WHEN THE setTimeout()
// COMPLETES, IT CALLS THIS FUNCTION
void servo_OFF() {
digitalWrite(18, LOW);
}
BLYNK_WRITE(V1) {
if ( param.asInt() ) {
servo_ON(255); // ENTER MOVEMENT VALUE AS ARGUMENT
timer.setTimeout(1500, servo_OFF); // AFTER 1500ms (1.5s), RUN servo_OFF() ONCE
} else {
servo_ON(10); // ENTER MOVEMENT VALUE AS ARGUMENT
timer.setTimeout(1500, servo_OFF);
}
//--------------
void setup() {
pinMode(18, OUTPUT);
Serial.begin(9600);
delay(10);
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
}
void loop() {
timer.run();
Blynk.run();
}