Skip to content

How can I record a voice at a custom time? #309

Answered by pschatzmann
xandyxor asked this question in Q&A
Discussion options

You must be logged in to vote

You can use millis() which provides the time in milliseconds since the start of the microcontroller.
uint64_t now = millis();
uint64_t start = now + 5000; // in 5 seconds
uint64_t end = now + 15000; // in 15 seconds

Then you just copy the audio data when millis()>start && millis<end;
If you copy to a file you need to add some additional logic to close the file (only once!) when it is done.

If you want to use time in hours and minutes you will need to install an NTP library or RTC module: Google will help you!

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by pschatzmann
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #308 on August 25, 2022 15:36.