-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathserialControl.ino
More file actions
38 lines (30 loc) · 790 Bytes
/
serialControl.ino
File metadata and controls
38 lines (30 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <btAudio.h>
btAudio audio = btAudio("ESP_Speaker");
String command;
void setup() {
// Streams audio data to the ESP32
audio.begin();
// Re-connects to last connected device
audio.reconnect();
// Outputs the received data to an I2S DAC, e.g. https://www.adafruit.com/product/3678
int bck = 26;
int ws = 27;
int dout = 25;
audio.I2S(bck, dout, ws);
// Opens the serial port
Serial.begin(115200);
}
void loop() {
delay(300);
// check if data is available
if(Serial.available()){
//read until a terminator. after this point there should only be numbers
command = Serial.readStringUntil('#');
if(command.equals("vol")){
//read and set volume
float vol =Serial.parseFloat();
Serial.println("Changing Volume");
audio.volume(vol);
}
}
}