In this Project, we will see about how to EEPROM in Arduino with LEDs .
Circuit Diagram:
Arduino Code:
dummy_eeprom_code.ino
#include <EEPROM.h> void setup() { Serial.begin(9600); EEPROM.write(12,73); int k = EEPROM.read(12); Serial.println(k); } void loop() { }
eeprom_led_control_code.ino
/* * Code written by Sdev * https://youtube.com/sdevelectronics */ #include <EEPROM.h> #include <IRremote.h> int load_status_1,load_status_2,load_status_3,load_status_4; #define LED1 5 #define LED2 4 #define LED3 3 #define LED4 2 int RECV_PIN = 11; IRrecv irrecv(RECV_PIN); decode_results results; void setup(){ Serial.begin(9600); pinMode(LED1,OUTPUT); pinMode(LED2,OUTPUT); pinMode(LED3,OUTPUT); pinMode(LED4,OUTPUT); irrecv.enableIRIn(); // Start the receiver check_load_status(); } void loop() { if (irrecv.decode(&results)) { Serial.println(results.value, HEX); if (results.value == 0x80BF916E) { //red if(load_status_1){ load_status_1 = 0; digitalWrite(LED1,load_status_1); EEPROM.update(0, load_status_1); }else{ load_status_1 = 1; digitalWrite(LED1,load_status_1); EEPROM.update(0, load_status_1); } } if (results.value == 0x80BF21DE) { //green if(load_status_2){ load_status_2 = 0; digitalWrite(LED2,load_status_2); EEPROM.update(1, load_status_2); }else{ load_status_2 = 1; digitalWrite(LED2,load_status_2); EEPROM.update(1, load_status_2); } } if (results.value == 0x80BF9B64) { //yellow if(load_status_3){ load_status_3 = 0; digitalWrite(LED3,load_status_3); EEPROM.update(2, load_status_3); }else{ load_status_3 = 1; digitalWrite(LED3,load_status_3); EEPROM.update(2, load_status_3); } } if (results.value == 0x80BF6996) { //blue if(load_status_4){ load_status_4 = 0; digitalWrite(LED4,load_status_4); EEPROM.update(3, load_status_4); }else{ load_status_4 = 1; digitalWrite(LED4,load_status_4); EEPROM.update(3, load_status_4); } } irrecv.resume(); // Receive the next value } delay(100); } void check_load_status(){ load_status_1 = EEPROM.read(0); load_status_2 = EEPROM.read(1); load_status_3 = EEPROM.read(2); load_status_4 = EEPROM.read(3); digitalWrite(LED1,load_status_1); digitalWrite(LED2,load_status_2); digitalWrite(LED3,load_status_3); digitalWrite(LED4,load_status_4); }
Youtube Video Tutorial:
Download our official Android App in PlayStore. Click Here
You can get the all the required files (like Circuit Diagram, Arduino.ino file, Libraries Used, and others) for the project in ZIP format and much more...
Hi bro...
ReplyDeleteI'm from bangladesh..
I Need your help. .
I make a program for ac light and fan control but i don't know how can use eeprom this arduino programm..
Do you can help me. ..?