Simple Record and Playback

Introduction: Simple Record and Playback

About: I am here to share what I make. Hopefully, you can learn from watching what I have done and even improve upon it. As an Amazon Associate I earn from qualifying purchases.

This project allows you to "record" sensory input and store it for later use. The information is stored in EEPROM instead of dynamic memory so that it can be remembered even when the board is shut down (like a tiny hard drive).


Step 1: Make the Circuit

Make the circuit according to the diagram above:

  • Potentiometer to pin A0
  • Button to pin D2
  • Servo to pin D3
  • Led to pin D13

If the above simulation does not load, see it here.

Step 2: Upload Code

Upload this code to your Arduino (no additional library installations required):

#include <Servo.h>
#include <EEPROM.h>//used to store recorded values
Servo myServo;
float resolution = 1000;//MUST be less than EEPROM.length()
float recordTime = 5; //delay time
bool recording = false;
void setup() {
 pinMode(13, OUTPUT); //status led
 pinMode(2, OUTPUT);
 digitalWrite(2, HIGH);
void loop() {
 if (recording == true) {//record
   for (int i = 1; i <= resolution; i++) {
     digitalWrite(13, HIGH); //light status led
     int val = map(analogRead(A0), 0, 1023, 0, 180);
     EEPROM.write(i, val);
   digitalWrite(13, LOW); //turn off status led
   delay(1000);//give time for person
   recording = false;
 else {
   for (int i = 1; i <= resolution; i++) {//playback
     if (digitalRead(2) == 0) {//stop playback and record new values
       recording = true;
     int readval =;
   digitalWrite(13, HIGH); //show a new repeat
   digitalWrite(13, LOW);

Note the comment that says //MUST be less than EEPROM.length()

To find the size of your board's EEPROM storage, uncomment the line //Serial.println(; This will print the size of EEPROM in the serial monitor, and you can change the value of the noted variable accordingly.

Step 3: How to Use

To use this circuit, you simply press the button to begin recording and input the desired information through a potentiometer. Now, the board will repeat your actions endlessly (and it blinks an led each iteration) until you press the button again to record new actions. You may also vary the amount of time recorded by changing the values of resolution and recordTime.

Step 4: Notes

This code uses a ton of EEPROM memory on the Arduino, so are some solutions:

  • Instead of a "smooth" recording, you could just have it record one position at a time and have it be more "jumpy." Just move the servo to a new position and press a button to keep it. Do this until you have all the positions you want.
  • Store in PROGMEM (program memory) instead of EEPROM
  • Use a regular integer array instead of EEPROM if you don't need to save information during a power loss.
  • Write to external storage such as a microSD card

Be the First to Share


    • Puzzles Challenge

      Puzzles Challenge
    • Rice & Grains Challenge

      Rice & Grains Challenge
    • Lamps Challenge

      Lamps Challenge