What were you hoping it would do? It's difficult to work out because the code makes no real sense. I hope its not what the comment says cus that'll never happen.Steve
This sort of problem requires a state-machine. Various events and time-outs are used to trigger transistions between states.Here you have states like idle, dot_or_dash, dash.When a beep starts you want to transition idle -> dot_or_dash and record the time.When in dot_or_dash state and the time since entering the state goes over the threshold you transistionto dash state. Beep ending transitions dot_or_dash to idle and emits a dot. Beep ending transistions dash state to idle and emits a dash.You'll need a few more states for recognizing word gaps.
The state machine MarkT references is usually implemented in Arduino land with the switch/case construct. There are examples and explanations all over the web and in the tutorials topic on this site.In addition, there's the https://www.arduino.cc/reference/en/ page where this and many other essential parts of the language are listed.
Your life would be a lot easier if instead of a plain microphone you used a sound detector board with the threshold built-in and a digital output - above threshold/below threshold. Something like https://www.sparkfun.com/products/12642Then you would use the StateChangeDetection technique from the IDE example of that name and just measure the time between going above and coming back down to below.Steve