/* Author: Kenny Z License: Creative Commons Attribution Share-Alike Description: A small keyboard that can play tones from c7 to C8, with auto record, and a button for playback. */ #define SPK 13 #define PLAYBACK_BTN 12 #define BUFFERSIZE 160 int keys[] = {2,3,4,5,6,7,8,9}; //int tones[] = {2093,1976,1760,1568,1397,1319,1175,1047}; int tones[] = {1047,1175,1319,1397,1568,1760,1976,2093}; int length = sizeof keys/sizeof *keys; // for recording int count = 0; int recorder[BUFFERSIZE]; unsigned long interval[BUFFERSIZE]; unsigned long pauseInterval[BUFFERSIZE]; void setup() { pinMode(SPK,OUTPUT); pinMode(PLAYBACK_BTN,INPUT); for(int i=0; i=BUFFERSIZE) count=0; // playback button if(digitalRead(PLAYBACK_BTN)==HIGH){ playback(); playback_btn=1; } // for each keyboard key for(int i=0; i