Audio adapter input all -1

Status
Not open for further replies.

lorencc

Member
Feeding a 1V pp 1 KHz square wave into LineIn. All I get is -1. Any ideas?

-----------------------------------------------------------------------------------------

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

AudioInputI2S i2s2;
AudioRecordQueue queue1;
AudioConnection patchCord1(i2s2, 0, queue1, 0);
AudioControlSGTL5000 sgtl5000_1;

const int myInput = AUDIO_INPUT_LINEIN;

int mode = 0; // 1=stopped, 0=recording

int Count = 0;

int Time = 10;
int NRecords = (Time*AUDIO_SAMPLE_RATE_EXACT*4)/256;

int led = 13;

File frec;

void setup() {

pinMode(led, OUTPUT);
Serial.begin(57600);

AudioMemory(60);

sgtl5000_1.enable();
sgtl5000_1.inputSelect(myInput);
sgtl5000_1.volume(0.5);

// Initialize the SD card
SPI.setMOSI(7);
SPI.setSCK(14);
if (!(SD.begin(10))) {
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}

startRecording();
Count = 0;
}

////////////////////////////////////////////////////////////////////////

void startRecording() {
Serial.println("startRecording");
if (SD.exists("RECORD2.RAW")) {.
SD.remove("RECORD2.RAW");
}
frec = SD.open("RECORD2.RAW", FILE_WRITE);
if (frec) {
queue1.begin();
}
}

//////////////////////////////////////////////////////////////////////////////

void flushRecording() {
Serial.println("flushRecording");
queue1.end();
while (queue1.available() > 0) {
queue1.freeBuffer();
}
frec.close();
}

///////////////////////////////////////////////////////////////////////////

void loop() {

byte *b;

if (mode == 1)
return;

while (queue1.available() > 0) {
Count++;
b = (byte*)queue1.readBuffer();
if (Count%100 == 0) {
Serial.print("record ");
Serial.println(Count);
};
frec.write(b, 256);

queue1.freeBuffer();
if (Count >= NRecords) {
flushRecording();
mode = 1;
}
}
}
 
Zeroing the buffers when I release them and still I get -1.

Checked all the solder connections.

The ground lines are all tied, so that's not it.

Is there some API setting I'm missing.
 
Found it.
Code:
pinMode(led, OUTPUT);
You can't use pin 13 as the led output because it is used by the audio board as an input.

Pete
 
Status
Not open for further replies.
Back
Top