record and play tone()

i have a project to do
i made a "piano" with pushbuttons and tone fucntion
i want also add rec and play,so i can record all the notes that i vv played and then to play the recorded one
Do anyone know how i can do this, i think i can do with array but i dont know how exactly use it and i have to give the project next week
thanks in advance

Welcome to the forums. Please read the sticky post at the top of the forum so you can learn how to get the most out of this forum.

Without any schematic or code included in your post, it is very difficult help other than

"yes, it is possible and yes, you should probably use arrays"

Possibly useful link.

const int pushButton=3;
const int pushButton2=4;
const int pushButton3=8;
const int ledPin=13;
int buttonState = 0;
int buttonState2 = 0;
int buttonState3 = 0;
int x=0;

void setup(){
pinMode(pushButton, INPUT); //Δηλωση pushButton ως εισοδο
pinMode(pushButton2, INPUT);//Δηλωση pushButton ως εισοδο
pinMode(pushButton3, INPUT);
pinMode(ledPin, OUTPUT);

tmrpcm.speakerPin = 9;
tmrpcm.setVolume(1); //0 to 7. Set volume level

// Unpressed

void loop(){
buttonState = digitalRead(pushButton);
buttonState2 = digitalRead(pushButton2);
buttonState3 = digitalRead(pushButton3);
int mystore[100];

if(buttonState == HIGH)
for(int x = 0; x<10; x++)

if (buttonState2 == HIGH)
for(int x = 0; x<10; x++)
if (buttonState3 == HIGH)


i m sure that is not correct but check if i m closed

Please read the sticky post at the top of the forum. It will teach you how to post your code using code tags so you code doesn’t look like plain text with odd characters in it.

A couple of things…

in you are using tmrpcm, you need to include the library in your sketch, typically at the top along with declaring on abject of that type

#include <TMRpcm.h>           //  also need to include this library...

TMRpcm tmrpcm;

Your buttons are defines as INPUT which means you need to have external pull-up resistors attached. Do you have them attached? If not, your buttons will be flaky. Without a schematic, (even a hand drawn one) only you will know. A more common approach is to connect one side of a button to ground and the other side to an input pin and then declare that pin as INPUT_PULLUP. This makes the button read HIGH when not pressed and LOW when pressed.

Your array ‘mystore’ is declared inside loop(). This means that every time through loop, you get a new version of mystore. You want to move that declaration outside of loop so it is a global variable and retains its values for the life of the program. This will allow you to store and read back previous values.

Since the rest of the code has odd characters in it, I’m not really sure about it…