This project contains two libraries. PlayerRecorder
to record and play back analogue data. And SimpleSample
, to set a sample rate for collecting data.
PlayerRecorder
helps you record analog data to an SD file. After the data is recorded, you can playback the data through your program. I created this so that I could record my sleep data and then play it back through some program when I'm awake in order develop and fine to tune my program to detect certain parts of sleep. Otherwise I had to develop my programs in real time. Not an easy task when you're asleep!
- Add
PlayerRecorder
to a program. - Set
PlayerRecorder
set to record (true
). - Run the program.
- Stop the program.
- Upload the same program but this time with
PlayerRecorder
set to playback (false
). - Run the program and you will have the same exact sequence of events in your program as when you recorded the data.
There's an issue in the PlayerRecorder.cpp
library. I had to hardcode the data filename into parts of the library. In the platform.io IDE, I couldn't use the variable _fileName
for SD.remove("firsttry.txt")
or SD.exists("firsttry.txt")
. So you have to change that to your file name or figure out how to use the variable _fileName
.
Using the _fileName
in SD.remove(_fileName.c_str())
gave me this error:
argument of type "const char *" is incompatible with parameter of type "char *"C/C++(167)
-
Get platform.io to use arduino in VSCode.
-
Import this project following the video in #1.
-
Plug in arduino with SD card attached. I used Arduino Uno. You can connect some sensors to A0 and A1 to get some values to record.
SD card pins Arduino UNO
- CS: pin 5 (can be any pin in reality, but 5 is hard coded into this project
SD.begin(5)
) - MOSI: 11
- MISO: 12
- SCK: 13
- GND: GND
- 5v: 5v
- CS: pin 5 (can be any pin in reality, but 5 is hard coded into this project
-
Set
record = true
inplayer_recorder_example.cpp
-
Upload and run
player_recorder_example.cpp
to your arduino to record. -
Set
record = false
inplayer_recorder_example.cpp
-
Upload and run
player_recorder_example.cpp
to your arduino to playback the data you just recorded.