Implement Discord mute/deafen status detection and control via serial communication

This commit is contained in:
2025-01-13 14:36:02 +01:00
parent 110b0daebb
commit 2fdfa7d3df
6 changed files with 104 additions and 1 deletions
+31 -1
View File
@@ -1,7 +1,12 @@
#define MUTE_PIN 18
#define DEAFEN_PIN 19
void setup()
{
pinMode(16, INPUT_PULLUP); // D16 for "mute" button
pinMode(16, INPUT_PULLUP); // D16 for "mute" button
pinMode(17, INPUT_PULLUP); // D17 for "deafen" button
pinMode(MUTE_PIN, OUTPUT);
pinMode(DEAFEN_PIN, OUTPUT);
Serial.begin(115200);
}
@@ -18,4 +23,29 @@ void loop()
Serial.println("deafen");
delay(200); // Debounce delay
}
if (Serial.available() > 0)
{
String input = Serial.readStringUntil('\n');
if (input == "Mute: True, Deafen: False")
{
digitalWrite(MUTE_PIN, HIGH);
digitalWrite(DEAFEN_PIN, LOW);
}
else if (input == "Mute: True, Deafen: True")
{
digitalWrite(MUTE_PIN, HIGH);
digitalWrite(DEAFEN_PIN, HIGH);
}
else if (input == "Mute: False, Deafen: False")
{
digitalWrite(MUTE_PIN, LOW);
digitalWrite(DEAFEN_PIN, LOW);
}
else if (input == "Mute: False, Deafen: True")
{
digitalWrite(MUTE_PIN, LOW);
digitalWrite(DEAFEN_PIN, HIGH);
}
}
}