TMRh20 / TMRpcm

Arduino library for asynchronous playback of PCM/WAV files direct from SD card. Arduino Uno,Nano,Mega etc supported
http://tmrh20.blogspot.com
592 stars 178 forks source link

Recording device #171

Closed AxelWi closed 5 months ago

AxelWi commented 2 years ago

Hi! I built this one https://www.instructables.com/Make-Your-Own-Spy-Bug-Arduino-Voice-Recorder/ I used the similar hardware and connected it according to the schedule. But edited the code since the code he used didn't work. Also tried with the example code you have published But when I try to record it only saves 1kb files. So I get no recording files just the file name i think?

Code I use:

include

include

include

define SD_ChipSelectPin 10

define ButtonPin 2

define LEDPin 6

define AudioPin A0

TMRpcm audio; char filnamn[64]; int audiofile = 0; unsigned long i = 0; bool recmode = false; bool button = false; void setLed(bool on) { digitalWrite(LEDPin, on ? HIGH : LOW); } void setup() { pinMode(AudioPin, INPUT); pinMode(LEDPin, OUTPUT); pinMode(ButtonPin, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(ButtonPin), buttonIRQ, LOW); SD.begin(SD_ChipSelectPin); audio.CSPin = SD_ChipSelectPin; } void buttonIRQ() { for (i=0; i < 300000; i++); button = true; } void loop() { if (button) { button = false; if (!recmode) { recmode = true; audiofile++; setLed(true); sprintf(filnamn, "ljud%04d.wav", audiofile); audio.startRecording(filnamn, 16000, A0); } else { recmode = false; setLed(false); audio.stopRecording(filnamn); } } }

rickyelqasem commented 1 year ago

I think you need SDFAT