This commit is contained in:
Sergey Karmanov 2024-02-02 19:11:14 +03:00
parent 0f2d7f3c47
commit 0ca4764761
6 changed files with 70 additions and 1 deletions

BIN
ESP Вариант.fzz Normal file

Binary file not shown.

BIN
NANO Вариант.fzz Normal file

Binary file not shown.

View File

@ -1 +1,26 @@
# I-am-just-a-fish
![IDE](https://img.shields.io/badge/Work%20in-Arduino%20IDE-green)
## О проекте
Небольшое устройство воспроизводящее звук и управляющее двигателем, созданное ради шутки, а точнее ради мема с крутящимися объектами под музыку.
## Инструкция по запуску
1) Подготовить и отформатировать sd карту в формат FAT32
2) Загрузить аудиофайл на флешку (MP3, WAV, WMA)
3) Открыть `src.ino` в Arduino IDE
4) Выбрать COM порт и модель платы
5) Изменить время до оставноки двигателя (`MUSIC_TIME` в коде)
6) Прошить
## Схема устройства
### Arduino
<img src="img/NANO Вариант.png" height="250" />
### ESP8266 Lolin
<img src="img/ESP Вариант.png" height="250" />
## Библиотеки
* [DFPlayerMini_Fast](https://github.com/PowerBroker2/DFPlayerMini_Fast)

BIN
img/ESP Вариант.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 KiB

BIN
img/NANO Вариант.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 KiB

44
src/src.ino Normal file
View File

@ -0,0 +1,44 @@
#include <DFPlayerMini_Fast.h>
#include <SoftwareSerial.h>
SoftwareSerial playerSerial(4, 5); // RX, TX
DFPlayerMini_Fast myMP3;
int buttonState = 0;
#define MUSIC_TIME 140000 // время песни в мс (для остановки двигателя)
uint32_t tmr; // переменная таймера
void setup() {
Serial.begin(115200);
playerSerial.begin(9600);
myMP3.begin(playerSerial, true);
delay(100);
Serial.println("Установка максимальной громкости");
myMP3.volume(30);
Serial.println("Воспроизведение остановлено");
myMP3.stop();
pinMode(15, OUTPUT);
pinMode(16, INPUT);
analogWrite(15, 0);
}
void loop() {
buttonState = digitalRead(16);
if (buttonState == HIGH) {
Serial.println("Устройство активировано");
myMP3.play(1);
analogWrite(15, 120);
tmr = millis();
}
if (millis() - tmr >= MUSIC_TIME) {
analogWrite(15, 0);
}
}