#define LED_PIN 11 #define LED_COUNT 5 #define SIGNAL_PIN 3 void setup() { vector> buffMethods; function currentMethod; bool busy=false; float startTime; float unit = 60; //dit is 60 ms pinMode(11, OUTPUT); } void loop() { //input handling // freq = fft() // letter = letters[freq] if (letter){ vector> methods = getMethods(letter); //add methods to buffer //note methods are in reverse of reality so when we pop off the back later it is in order, add to front // e.g. buff={3,2,1} methodstoAdd={6,5,4} -> buff{6,5,4,3,2,1} buffMethods.insert(buffMethods.begin(), methods.begin(), methods.end()); } //sending logic to LED if(!busy){ if (buffMethods.size()>0){ //not empty //pop, assign to current, and run currentMethod=buffMethods[buffMethods.size()-1]; buffMethods.pop_back();//removes without return currentMethod(); } } else{ currentMethod(); } //code to display buffer? } vector> getMethods(int letter){ //WRITE ALL METHODS IN REVERSE MORSECODE; vector> methodsLetter; switch(letter){ case(1): // a methodsLetter={&space, &space, &space, &dash, &space, &dot}; default: //default to nothing or "b" which is pretty recognizable methodsLetter={&space}; } return methodsLetter; } void dot(){ if(!busy){ busy=true; startTime= millis(); digitalWrite(11, HIGH); //LED ON } if (millis()-startTime>=unit){ //dot = 1 unit busy=false; digitalWrite(11, LOW); //LED OFF } } void dash(){ if(!busy){ busy=true; startTime= millis(); digitalWrite(11, HIGH); //LED ON } if (millis()-startTime>=3*unit){ //dash = 3 units busy=false; digitalWrite(11, LOW); //LED OFF } } void space(){ //essentially do nothing; aka pause between flashing of morse code if(!busy){ busy=true; startTime= millis(); // digitalWrite(11, LOW); //LED OFF; shouldnt be necessary } if (millis()-startTime>=unit){ //space = 1 unit busy=false; } } //buffer.add() for array //if (sizeof(buff)-bufferIndex >= sizeof(methods)){ // for (int i =0; i