Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EEPROM BLYNK #1046

Open
Akbar0333 opened this issue Oct 22, 2023 · 0 comments
Open

EEPROM BLYNK #1046

Akbar0333 opened this issue Oct 22, 2023 · 0 comments

Comments

@Akbar0333
Copy link

Akbar0333 commented Oct 22, 2023

#define BLYNK_TEMPLATE_ID "TMPL31iM8MY9P"
#define BLYNK_TEMPLATE_NAME "home cotrol"
#define BLYNK_AUTH_TOKEN "QOxacMhJ9hFRpei_laFTAL3N8EHBt8sQ"
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <EEPROM.h>
#include <BlynkSimpleEsp8266_SSL.h>
#define ssids "Jio4 AS"
#define passw "akbar392"

#define led1 D1
#define led2 D2
#define led3 D3
#define led4 D4
#define led5 D5
#define led6 D6
#define led7 D7
#define led8 D8
#define wifihi D10
#define wifiLo D9
int load1=0;
int load2=0;
int load3=0;
int load4=0;
int load5=0;
int load6=0;
int load7=0;
int load8=0;

char auth[] = BLYNK_AUTH_TOKEN;

char ssid[] = ssids;
char pass[] = passw;

void setup()
{
EEPROM.begin(512);
Serial.begin(115200);

load1 = EEPROM.read(1);
load2 = EEPROM.read(2);
load3 = EEPROM.read(3);
load4 = EEPROM.read(4);
load5 = EEPROM.read(5);
load6 = EEPROM.read(6);
load7 = EEPROM.read(7);
load8 = EEPROM.read(8);

pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
pinMode(led8, OUTPUT);
pinMode(wifihi, OUTPUT);
pinMode(wifiLo, OUTPUT);

updateLed();

Blynk.begin(auth, ssid, pass);

}

void loop()
{
if(WiFi.status() != WL_CONNECTED)
{
digitalWrite(wifihi,HIGH);
digitalWrite(wifiLo,LOW);

}  
else{
    digitalWrite(wifihi,LOW);
    digitalWrite(wifiLo,HIGH);
    
}

Blynk.run();

}

BLYNK_WRITE(V1){
load1 = param.asInt();
updateLed();
}

BLYNK_WRITE(V2){
load2 = param.asInt();
updateLed();
}
BLYNK_WRITE(V3){
load3 = param.asInt();
updateLed();
}

BLYNK_WRITE(V4){
load4 = param.asInt();
updateLed();
}
BLYNK_WRITE(V5){
load5 = param.asInt();
updateLed();
}

BLYNK_WRITE(V6){
load6 = param.asInt();
updateLed();
}
BLYNK_WRITE(V7){
load7 = param.asInt();
updateLed();
}

BLYNK_WRITE(V8){
load8 = param.asInt();
updateLed();
}

BLYNK_WRITE(V9){
load1 = param.asInt();
load2 = param.asInt();
load3 = param.asInt();
load4 = param.asInt();
load5 = param.asInt();
load6 = param.asInt();
load7 = param.asInt();
load8 = param.asInt();
updateLed();

}

BLYNK_WRITE(V10){

int value = param.asInt();
value ? digitalWrite(led1, HIGH) :
digitalWrite(led1, LOW);
}

BLYNK_WRITE(V11){
int value = param.asInt();
value ? digitalWrite(led2, HIGH) :
digitalWrite(led2, LOW);
}
BLYNK_WRITE(V12){
int value = param.asInt();
value ? digitalWrite(led3, HIGH) :
digitalWrite(led3, LOW);
}

BLYNK_WRITE(V13){
int value = param.asInt();
value ? digitalWrite(led4, HIGH) :
digitalWrite(led4, LOW);
}
BLYNK_WRITE(V14){
int value = param.asInt();
value ? digitalWrite(led5, HIGH) :
digitalWrite(led5, LOW);
}

BLYNK_WRITE(V15){
int value = param.asInt();
value ? digitalWrite(led6, HIGH) :
digitalWrite(led6, LOW);
}
BLYNK_WRITE(V16){
int value = param.asInt();
value ? digitalWrite(led7, HIGH) :
digitalWrite(led7, LOW);
}

BLYNK_WRITE(V17){
int value = param.asInt();
value ? digitalWrite(led8, HIGH) :
digitalWrite(led8, LOW);
}

BLYNK_WRITE(V18){
int value = param.asInt();
value ? digitalWrite(led1, HIGH) :
digitalWrite(led1, LOW);
value ? digitalWrite(led2, HIGH) :
digitalWrite(led2, LOW);
value ? digitalWrite(led3, HIGH) :
digitalWrite(led3, LOW);
value ? digitalWrite(led4, HIGH) :
digitalWrite(led4, LOW);
value ? digitalWrite(led5, HIGH) :
digitalWrite(led5, LOW);
value ? digitalWrite(led6, HIGH) :
digitalWrite(led6, LOW);
value ? digitalWrite(led7, HIGH) :
digitalWrite(led7, LOW);
value ? digitalWrite(led8, HIGH) :
digitalWrite(led8, LOW);
}

void updateLed(){
digitalWrite(led1, load1);
digitalWrite(led2, load2);
digitalWrite(led3, load3);
digitalWrite(led4, load4);
digitalWrite(led5, load5);
digitalWrite(led6, load6);
digitalWrite(led7, load7);
digitalWrite(led8, load8);
updateEEPROM();
}

void updateEEPROM(){
EEPROM.put(1, load1);
EEPROM.put(2, load2);
EEPROM.put(3, load3);
EEPROM.put(4, load4);
EEPROM.put(5, load5);
EEPROM.put(6, load6);
EEPROM.put(7, load7);
EEPROM.put(8, load8);
EEPROM.commit();
}

@Akbar0333 Akbar0333 changed the title Kuchhna kuchch EEPROM BLYNK Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant