my whole code for my projct is…
/*************************************************************
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.
*************************************************************
WARNING!
It's very tricky to get it working. Please read this article:
http://help.blynk.cc/hardware-and-libraries/arduino/esp8266-with-at-firmware
You’ll need:
- Blynk App (download from AppStore or Google Play)
- Arduino Uno board
- Decide how to connect to Blynk
(USB, Ethernet, Wi-Fi, Bluetooth, ...)
There is a bunch of great example sketches included to show you how to get
started. Think of them as LEGO bricks and combine them as you wish.
For example, take the Ethernet Shield sketch and combine it with the
Servo example, or choose a USB sketch and add a code from SendData
example.
*************************************************************/
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
//uncomment this line if using a Common Anode LED#define COMMON_ANODE
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "b7d6a71cdaef45b5844f5695f57badb8";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "rd";
char pass[] = "rohit2237424";
int D2, D3;
boolean buttonState = HIGH; //set the initial direction of the relays, see below for if(HIGH) logic
// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial
// or Software Serial on Uno, Nano...
//#include <SoftwareSerial.h>
//SoftwareSerial EspSerial(2, 3); // RX, TX
// Your ESP8266 baud rate:
#define ESP8266_BAUD 115200
ESP8266 wifi(&EspSerial);
const int redPin = 10;
const int greenPin = 11;
const int bluePin = 12;
unsigned int rgbColour[3];
void setup()
{
// Debug console
Serial.begin(9600);
// Set ESP8266 baud rate
EspSerial.begin(ESP8266_BAUD);
delay(10);
Blynk.begin(auth, wifi, ssid, pass);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
digitalWrite(12, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
// You can also specify server:
//Blynk.begin(auth, wifi, ssid, pass, "blynk-cloud.com", 8442);
//Blynk.begin(auth, wifi, ssid, pass, IPAddress(192,168,1,100), 8442);
}
void loop()
{
Blynk.run();
// You can inject your own code or combine it with other sketches.
// Check other examples on how to communicate with Blynk. Remember
// to avoid delay() function!
// Start off with red.
}
BLYNK_WRITE(V1)
{
if (param.asInt()==1) {
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);//button presed
} else {
digitalWrite(7, LOW);
digitalWrite(8, LOW);//button released
}
}
BLYNK_WRITE(V2)
{
if (param.asInt()==1) {
digitalWrite(2, HIGH);
digitalWrite(6, HIGH);//button presed
digitalWrite(7, HIGH);
} else {
digitalWrite(2, LOW);
digitalWrite(6, LOW);//button released
digitalWrite(7, LOW);
}
}
BLYNK_WRITE(V3)
{
if (param.asInt()==1) {
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);//button presed
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
} else {
digitalWrite(4, LOW);
digitalWrite(5, LOW);//button released
digitalWrite(6, LOW);
digitalWrite(7, LOW);
}
}
BLYNK_WRITE(V4)
{
if (param.asInt()==1) {
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);//button presed
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, HIGH);
digitalWrite(8, HIGH);
} else {
digitalWrite(2, LOW);
digitalWrite(3, LOW);//button released
digitalWrite(4, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
}
}
BLYNK_WRITE(V6)
{
int pinvalue = param.asInt();
if (pinvalue==1)
{
rgbColour[0] = 0;
rgbColour[1] = 0;
rgbColour[2] = 0;
// Choose the colours to increment and decrement.
for (int decColour = 0; decColour < 3; decColour += 1) {
int incColour = decColour == 2 ? 0 : decColour + 1;
// cross-fade the two colours.
for(int i = 0; i < 255; i += 1) {
rgbColour[decColour] -= 1;
rgbColour[incColour] += 1;
setColourRgb(rgbColour[0], rgbColour[1], rgbColour[2]);
delay(5);
}
}
}
else {
digitalWrite(12, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
}
}
void setColourRgb(unsigned int red, unsigned int green, unsigned int blue) {
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}