Save data to EEPROM
hello
i'm doing project convert home theater analog potentiometer infrared controlled remote control periodic digital vol. sub. , back.
their work also, if iturn off arduino , starts them starts first resistance potentiometers, until volume.
now want save last volume value , when arduino initiate lets start in value.
i'm doing project convert home theater analog potentiometer infrared controlled remote control periodic digital vol. sub. , back.
their work also, if iturn off arduino , starts them starts first resistance potentiometers, until volume.
now want save last volume value , when arduino initiate lets start in value.
code: [select]
#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;
}
you have seen eeprom library , examples?
Arduino Forum > Using Arduino > Project Guidance > Save data to EEPROM
arduino
Comments
Post a Comment