switching the frequency between 440 and 880 every second

This commit is contained in:
2025-12-02 19:54:00 +01:00
parent c646128e10
commit 6678db4565

View File

@ -10,6 +10,9 @@ I2S i2s(OUTPUT);
#define BLOCKSIZE 64 // Heavy block size
#define BUFFERSIZE (2 * BLOCKSIZE) // Stereo interleaved
bool state;
int delta;
int16_t buffer[BUFFERSIZE];
inline int16_t float_to_i16(float x) {
@ -75,5 +78,12 @@ void setup() {
}
void loop() {
if (millis() - delta > 1000) {
int freq;
if (state) freq = 440;
else freq = 880;
hv->sendFloatToReceiver(hv_string_to_hash("osc_freq_input"), freq);
state = !state;
delta = millis();
}
}