Спасибо!
Код: Выделить всё
#include <avr/io.h>
#define F_CPU 1000000UL
#include <avr/eeprom.h>
#include <util/delay.h>
#define EEPROM_SECTION __attribute__ ((section (".eeprom"))) // для удобства написания/чтения программы
unsigned char ON=1;
unsigned char OFF=0;
unsigned char e=0;
unsigned char CANAL1;
uint8_t Mem1 EEPROM_SECTION=0;
void Memori()
{
eeprom_update_byte(&Mem1,CANAL1);
}
int main(void)
{
DDRD=1;
CANAL1=OFF;
CANAL1=eeprom_read_byte(&Mem1);
while(1)
{
_delay_ms(500);
e=e+1;
if (e>200)
{
Memori();
e=0;
}
if (bit_is_set(PIND,1))
CANAL1=OFF;
if (bit_is_set(PIND,2))
CANAL1=ON;
if(CANAL1==ON) PORTD |= _BV(PD0);
else PORTD &=~_BV(PD0);
}
}
