diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | platformio.ini | 16 | ||||
| -rw-r--r-- | src/main.cpp | 40 |
3 files changed, 58 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b9f3806 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.pio +.vscode diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..c5b5966 --- /dev/null +++ b/platformio.ini @@ -0,0 +1,16 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:attiny13a] +platform = atmelavr +board = attiny13a +framework = arduino + +upload_protocol = usbasp diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..0772645 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,40 @@ +#include <avr/io.h> +#include <util/delay.h> + +#define F_CPU 9600000UL +#define PIN_OUTPUT PB0 +#define TIME_WORK 15 // минут +#define TIME_PAUSE 25 // минут + +// Макрос для задержки на указанное количество минут +#define DELAY_MINUTES(min) \ + do \ + { \ + for (uint16_t m = 0; m < (min); m++) \ + { \ + for (uint16_t s = 0; s < 60; s++) \ + { \ + _delay_ms(1000); /* 1 секунда */ \ + } \ + } \ + } while (0) + +int main(void) +{ + // Отключаем АЦП и компаратор + ADCSRA &= ~(1 << ADEN); + ACSR |= (1 << ACD); + + // Настройка пинов + DDRB |= (1 << PB0) | (1 << PB1) | (1 << PB2) | (1 << PB3) | (1 << PB4); + PORTB &= ~((1 << PB0) | (1 << PB1) | (1 << PB2) | (1 << PB3) | (1 << PB4)); + + while (1) + { + PORTB |= (1 << PIN_OUTPUT); // LED ON + DELAY_MINUTES(TIME_WORK); // 15 минут + + PORTB &= ~(1 << PIN_OUTPUT); // LED OFF + DELAY_MINUTES(TIME_PAUSE); // 25 минут + } +}
\ No newline at end of file |
