Buzzer tests
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
#define KEY_DST GPIO_NUM_17 // D8
|
#define KEY_DST GPIO_NUM_17 // D8
|
||||||
|
|
||||||
// Buzzer
|
// Buzzer
|
||||||
#define BUZZER GPIO_NUM_0 // ! B1 <-> LED green
|
#define BUZZER GPIO_NUM_43 // TX
|
||||||
#define LEDC_CHANNEL 0
|
#define LEDC_CHANNEL 0
|
||||||
#define LEDC_TIMER_8_BIT 8
|
#define LEDC_TIMER_8_BIT 8
|
||||||
#define LEDC_BASE_FREQ 5000
|
#define LEDC_BASE_FREQ 5000
|
||||||
|
|||||||
38
src/main.cpp
38
src/main.cpp
@@ -287,17 +287,15 @@ void setup() {
|
|||||||
digitalWrite(LED_USER, LOW);
|
digitalWrite(LED_USER, LOW);
|
||||||
|
|
||||||
// Buzzer
|
// Buzzer
|
||||||
/*
|
|
||||||
ledcSetup(LEDC_CHANNEL, LEDC_BASE_FREQ, LEDC_TIMER_8_BIT);
|
ledcSetup(LEDC_CHANNEL, LEDC_BASE_FREQ, LEDC_TIMER_8_BIT);
|
||||||
ledcAttachPin(BUZZER, LEDC_CHANNEL);
|
ledcAttachPin(BUZZER, LEDC_CHANNEL);
|
||||||
// Test tone while booting
|
// Test tone while booting
|
||||||
if (ledcWriteTone(BUZZER, 4000) == 0) {
|
if (ledcWriteTone(LEDC_CHANNEL, 4000) == 0) {
|
||||||
Serial.println("Error setting buzzer tone");
|
Serial.println("Error setting buzzer tone");
|
||||||
} else {
|
} else {
|
||||||
delay(750);
|
delay(750);
|
||||||
ledcWriteTone(BUZZER, 0); // Buzzer off
|
ledcWriteTone(LEDC_CHANNEL, 0); // Buzzer off
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// Startup sequence: test all led and short beep buzzer
|
// Startup sequence: test all led and short beep buzzer
|
||||||
|
|
||||||
@@ -374,6 +372,25 @@ void setup() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void atariKeyclick() {
|
||||||
|
/*
|
||||||
|
* Anderer 12V-fähiger Buzzer!
|
||||||
|
*
|
||||||
|
Buzzer + → 12V
|
||||||
|
Buzzer – → IRLZ44N Drain
|
||||||
|
IRLZ44N Source → GND
|
||||||
|
ESP32 GPIO43 → 1kΩ resistor → Gate
|
||||||
|
ESP32 GND must be connected to the same GND as the 12V supply.
|
||||||
|
* */
|
||||||
|
ledcWriteTone(LEDC_CHANNEL, 3200);
|
||||||
|
delayMicroseconds(3000);
|
||||||
|
ledcWriteTone(LEDC_CHANNEL, 0);
|
||||||
|
delayMicroseconds(800);
|
||||||
|
ledcWriteTone(LEDC_CHANNEL, 3200);
|
||||||
|
delayMicroseconds(2000);
|
||||||
|
ledcWriteTone(LEDC_CHANNEL, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|
||||||
// Button pressed? (active low)
|
// Button pressed? (active low)
|
||||||
@@ -415,6 +432,9 @@ void loop() {
|
|||||||
if (digitalRead(KEY_4) == LOW) {
|
if (digitalRead(KEY_4) == LOW) {
|
||||||
Serial.println("Button detected: 4");
|
Serial.println("Button detected: 4");
|
||||||
button += 8;
|
button += 8;
|
||||||
|
|
||||||
|
atariKeyclick();
|
||||||
|
|
||||||
digitalWrite(LED_USER, HIGH); // Turn LED on
|
digitalWrite(LED_USER, HIGH); // Turn LED on
|
||||||
delay(500); // Keep it on 0.5s
|
delay(500); // Keep it on 0.5s
|
||||||
digitalWrite(LED_USER, LOW); // Turn LED off
|
digitalWrite(LED_USER, LOW); // Turn LED off
|
||||||
@@ -422,6 +442,11 @@ void loop() {
|
|||||||
if (digitalRead(KEY_5) == LOW) {
|
if (digitalRead(KEY_5) == LOW) {
|
||||||
Serial.println("Button detected: 5");
|
Serial.println("Button detected: 5");
|
||||||
button += 16;
|
button += 16;
|
||||||
|
|
||||||
|
ledcWriteTone(LEDC_CHANNEL, 3200);
|
||||||
|
delay(8);
|
||||||
|
ledcWriteTone(LEDC_CHANNEL, 0);
|
||||||
|
|
||||||
digitalWrite(LED_USER, HIGH); // Turn LED on
|
digitalWrite(LED_USER, HIGH); // Turn LED on
|
||||||
delay(500); // Keep it on 0.5s
|
delay(500); // Keep it on 0.5s
|
||||||
digitalWrite(LED_USER, LOW); // Turn LED off
|
digitalWrite(LED_USER, LOW); // Turn LED off
|
||||||
@@ -429,6 +454,11 @@ void loop() {
|
|||||||
if (digitalRead(KEY_6) == LOW) {
|
if (digitalRead(KEY_6) == LOW) {
|
||||||
Serial.println("Button detected: 6");
|
Serial.println("Button detected: 6");
|
||||||
button += 32;
|
button += 32;
|
||||||
|
|
||||||
|
ledcWriteTone(LEDC_CHANNEL, 3200);
|
||||||
|
delay(8);
|
||||||
|
ledcWriteTone(LEDC_CHANNEL, 0);
|
||||||
|
|
||||||
digitalWrite(LED_USER, HIGH); // Turn LED on
|
digitalWrite(LED_USER, HIGH); // Turn LED on
|
||||||
delay(500); // Keep it on 0.5s
|
delay(500); // Keep it on 0.5s
|
||||||
digitalWrite(LED_USER, LOW); // Turn LED off
|
digitalWrite(LED_USER, LOW); // Turn LED off
|
||||||
|
|||||||
Reference in New Issue
Block a user