File tree 1 file changed +8
-5
lines changed
libraries/ESP_I2S/examples/Simple_tone
1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change 24
24
2nd September 2021
25
25
Lucas Saavedra Vaz (lucasssvaz)
26
26
22nd December 2023
27
- anonZ
27
+ anon
28
28
10nd February 2025
29
29
*/
30
30
31
31
#include < ESP_I2S.h>
32
32
33
- // In fact, the GPIO pins are not fixed, most other pins can be used for the I2S function.
33
+ // The GPIO pins are not fixed, most other pins can be used for the I2S function.
34
34
#define I2S_LRC 25
35
35
#define I2S_BCLK 5
36
36
#define I2S_DIN 26
@@ -43,7 +43,7 @@ i2s_data_bit_width_t bps = I2S_DATA_BIT_WIDTH_16BIT;
43
43
i2s_mode_t mode = I2S_MODE_STD;
44
44
i2s_slot_mode_t slot = I2S_SLOT_MODE_STEREO;
45
45
46
- const int halfWavelength = ( sampleRate / frequency / 2 ) ; // half wavelength of square wave
46
+ const int halfWavelength = sampleRate / frequency / 2 ; // half wavelength of square wave
47
47
48
48
int32_t sample = amplitude; // current sample value
49
49
unsigned int count = 0 ;
@@ -70,9 +70,12 @@ void loop() {
70
70
sample = -1 * sample;
71
71
}
72
72
73
- i2s.write (sample); // Right channel
73
+ // Right channel, low 8 bit then hight 8 bit
74
+ i2s.write (sample);
74
75
i2s.write (sample >> 8 );
75
- i2s.write (sample); // Left channel
76
+
77
+ // Left channel, low 8 bit then hight 8 bit
78
+ i2s.write (sample);
76
79
i2s.write (sample >> 8 );
77
80
78
81
// increment the counter for the next sample
You can’t perform that action at this time.
0 commit comments