Hallo
Actually I want to make a LED Dimmer with Arduino with Remote Controll. I tried with online help , It was good. But I need some changing in it. Please help me for it.
I want to save last state of LED brightness level after turn it off. I want to save it in EEPROM . If I restart Arduino, It use last Brightness level information from EEPROM and turn LED on at last brightness level. Arduino use its last setting Automatically and I dont need to Turn it on from Remote Controller. I just change brightness from it. After that I can decrease LED brightness from Remote without Turn it on /Off.
Pleas help me for it.
Code for Dimmer LED Strip with TV Remote Controller
https://www.youtube.com/user/greatscottlab
#include <IRremote.h>
int bright;
int before;
int out=9; //connect your LED to pin 9
int steps=5; //dimmer steps, vary those to increase/decrease the steps between full brightness and turned off
int RECV_PIN = 11; //data out of IR receiver connects to pin 11
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup(){
irrecv.enableIRIn(); // start the receiver
before=0; //LED is turned off
bright=255; //brightness value is at maximum (255)
pinMode(out,OUTPUT);
}
void loop() {
if (irrecv.decode(&results)) {
if (results.value==0x20DF8D72){ //Code to turn the LED ON/OFF
if(before==0){ // if the LED was turned off, then we turn it on
digitalWrite(out,HIGH);
before=1; //LED is now turned on
}
else{
digitalWrite(out,LOW); //if the LED was turned on, then we turn it off
before=0;
bright=255;
}}
if (results.value==0x20DFF10E && before==1){ //Code to decrease the brightness
if(bright-255/steps<0){
analogWrite(out,bright);
}
else{
bright=bright-255/steps;
analogWrite(out,bright);
}}
if (results.value==0x20DF718E && before==1){ //Code to increase the brightness
if(bright+255/steps>255){
analogWrite(out,bright);
}
else{
bright=bright+255/steps;
analogWrite(out,bright);
}}
irrecv.resume();
}}