Skip to content

Commit 8519d67

Browse files
committed
Split begin; changed pin setups and duplex/simplex setup
1 parent 8d99a4d commit 8519d67

File tree

3 files changed

+160
-129
lines changed

3 files changed

+160
-129
lines changed

libraries/I2S/examples/SimpleTone/SimpleTone.ino

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
const int frequency = 440; // frequency of square wave in Hz
2121
const int amplitude = 500; // amplitude of square wave
2222
const int sampleRate = 8000; // sample rate in Hz
23+
const int bps = 16;
2324

2425
const int halfWavelength = (sampleRate / frequency); // half wavelength of square wave
2526

@@ -31,14 +32,14 @@ void setup() {
3132
Serial.println("I2S simple tone");
3233

3334
// start I2S at the sample rate with 16-bits per sample
34-
if (!I2S.begin(I2S_PHILIPS_MODE, sampleRate, 16)) {
35+
if (!I2S.begin(I2S_PHILIPS_MODE, sampleRate, bps)) {
3536
Serial.println("Failed to initialize I2S!");
3637
while (1); // do nothing
3738
}
39+
I2S.setDataOutPin(26);
3840
}
3941

4042
void loop() {
41-
if(I2S.availableForWrite() >= 2){
4243
if (count % halfWavelength == 0 ) {
4344
// invert the sample every half wavelength count multiple to generate square wave
4445
sample = -1 * sample;
@@ -50,5 +51,4 @@ void loop() {
5051

5152
// increment the counter for the next sample
5253
count++;
53-
}
5454
}

0 commit comments

Comments
 (0)