Hello everyone, today I need help with a project I'm working on.
I'm creating an audio guest book using a vintage GPO telephone I bought from Amazon, along with a Teensy 4.0 board and an audio shield. My first step was to solder the phone's micro-switch to the Teensy so it could recognize it. After that, I attempted to install my audio shield with a micro SD card. However, when I run my code in Arduino, it fails to detect the SD card, and my micro-switch code also stops working.
I've attached photos showing my setup.
I've placed my Teensy on my audio shield and added a 16GB SD card formatted to FAT32, but it seems like they're not connecting properly. When I run the code, I get an "initialization failed" error.
On my SD card, I only have a WAV file that I'd like to play when the phone is picked up.
If you have any ideas, I would appreciate your help. I'm a beginner and this is my first project, so there might be some simple mistakes in my setup.
this is my code
I'm creating an audio guest book using a vintage GPO telephone I bought from Amazon, along with a Teensy 4.0 board and an audio shield. My first step was to solder the phone's micro-switch to the Teensy so it could recognize it. After that, I attempted to install my audio shield with a micro SD card. However, when I run my code in Arduino, it fails to detect the SD card, and my micro-switch code also stops working.
I've attached photos showing my setup.
I've placed my Teensy on my audio shield and added a 16GB SD card formatted to FAT32, but it seems like they're not connecting properly. When I run the code, I get an "initialization failed" error.
On my SD card, I only have a WAV file that I'd like to play when the phone is picked up.
If you have any ideas, I would appreciate your help. I'm a beginner and this is my first project, so there might be some simple mistakes in my setup.
this is my code
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// Définition des objets audio
AudioPlaySdWav playSdWav;
AudioOutputI2S audioOutput;
AudioConnection patchCord1(playSdWav, 0, audioOutput, 0);
AudioConnection patchCord2(playSdWav, 1, audioOutput, 1);
AudioControlSGTL5000 sgtl5000_1;
const int switchPin = 0;
bool lastState = HIGH;
void setup() {
pinMode(switchPin, INPUT_PULLUP);
Serial.begin(9600);
AudioMemory(8);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
if (!SD.begin(BUILTIN_SDCARD)) {
Serial.println("initialization failed");
while (1);
}
}
void loop() {
bool isHandsetLifted = digitalRead(switchPin) == LOW;
if (isHandsetLifted != lastState) {
if (isHandsetLifted) {
Serial.println("Handset lifted");
if (playSdWav.isPlaying() == false) {
playSdWav.play("test.wav");
}
} else {
Serial.println("Handset down");
playSdWav.stop();
}
lastState = isHandsetLifted;
}
delay(100);
}