/**
Simon Game for ESP32-C3 with Score display
Copyright (C) 2023, Uri Shaked
Released under the MIT License.
*/
#include "pitches.h"
/**
Set up the Arduino board and initialize Serial communication
*/
void setup() {
pinMode(0, OUTPUT);
}
// A very short "beep" represented as raw PCM data
const uint8_t speech_data[] = { 128, 132, 140, 150, 160, 128, 132, 140, 150, 160, 128, 132, 140, 150, 160, 128, 132, 140, 150, 160, 128, 132, 140, 150, 160, 128, 132, 140, 150, 160, 128, 132, 140, 150, 160, 128, 132, 140, 150, 160, 128, 132, 140, 150, 160, };
void playSpeech() {
for (int i = 0; i < sizeof(speech_data); i++) {
// Set the PWM duty cycle to the value of the audio sample
ledcWrite(0, speech_data[i]);
// Wait for the next sample (e.g., for 8kHz, wait 125 microseconds)
delayMicroseconds(125);
}
}
/**
The main game loop
*/
void loop() {
playSpeech();
delay((10));
}