Hello
I'm doing a project to convert a home theater with analog potentiometer an infrared controlled remote control for periodic digital vol. sub. And back.
Their work will also, but if Iturn off the Arduino and starts them It starts with the first Resistance potentiometers, until volume.
Now I want to SAVE the Last volume Value and When The arduino Initiate lets start in This Value.
#include "IRLremote.h"
#include <DigiPotX9Cxxx.h>
DigiPot pot(3, 4, 5); //volumen
DigiPot pot2(6, 7, 8); //bass
DigiPot pot3(9, 10, 11);
const int interruptIR = 0;
uint8_t IRProtocol = 0; // Variables para recibir los datos
uint16_t IRAddress = 0;
uint32_t IRCommand = 0;
int Ledrojo = 13;
int Ledamarillo = 12;
void setup() {
Serial.begin(115200);
IRLbegin<IR_ALL>(interruptIR);
pinMode(Ledrojo, OUTPUT);
pinMode(Ledamarillo, OUTPUT);
}
void loop() {
// uint8_t oldSREG = SREG;
//cli();
if (IRProtocol)
{
if (IRCommand == 0x30CF) { //rele 1 on
digitalWrite(Ledrojo, HIGH);
Serial.println("rele1 ON");
}
if (IRCommand == 0x18E7) //relé1 off
{ digitalWrite(13, LOW);
Serial.println("rele1 OFF");
}
if (IRCommand == 0x10EF) //relé2 on
{ digitalWrite(12, HIGH);
Serial.println("rele2 ON");
}
if (IRCommand == 0x38C7) //relé2 off
{ digitalWrite(12, LOW);
Serial.println("rele2 OFF");
}
if (IRCommand == 0xA857) //+ volumen
{ pot.increase(5);
//digitalWrite(Ledrojo, HIGH);
Serial.println("+vol");
//delay(100);
//digitalWrite(Ledrojo, LOW);
}
if (IRCommand == 0xE01F) //- volumen
{ pot.decrease(5);
Serial.println("-vol");
//digitalWrite(Ledamarillo, HIGH);
//delay (100);
//digitalWrite(Ledamarillo, LOW);
}
if (IRCommand == 0x9867 ) //+ sub
{ pot2.increase(5);
Serial.println("+bass");
//digitalWrite(Ledrojo, HIGH);
//delay (100);
//digitalWrite(Ledrojo, LOW);
}
if (IRCommand == 0xB04F ) //- sub
{ pot2.decrease(5);
Serial.println("-bass");
//digitalWrite(Ledamarillo, HIGH);
//delay (100);
//digitalWrite(Ledamarillo, LOW);
}
if (IRCommand == 0xE21D ) //+ rear
{ pot3.increase(5);
Serial.println("+");
//digitalWrite(Ledrojo, HIGH);
// delay (100);
//digitalWrite(Ledrojo, LOW);
}
if (IRCommand == 0xA25D) //- rear
{ pot3.decrease(5);
Serial.println("-");
//digitalWrite(Ledamarillo, HIGH);
//delay (100);
//digitalWrite(Ledamarillo, LOW);
}
IRProtocol = 0;
}
}
void IREvent(uint8_t protocol, uint16_t address, uint32_t command)
{
IRProtocol = protocol; // Recogemos los valores y nos volvemos
IRAddress = address;
IRCommand = command;
}