TMRpcm
TMRpcm copied to clipboard
Recording device
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 <SD.h> #include <SPI.h> #include<TMRpcm.h> #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); } } }
I think you need SDFAT