Coding the SOS Morse code signal
This section describes the code necessary for turning the LED for showing the SOS Morse signal, which runs on the Blue Pill board, on and off. The following code shows the main functions used for defining the SOS Morse code message and for sending it to the board's output port. The next code segment defines the necessary dot, dash, and space values, as well as the port label:
int led=PB12; int dot_duration=150; int dash_duration=dot_duration*3; int shortspace_duration=dot_duration; int space_duration=dot_duration*7;
The next function sets up the output port (B12
) for turning the LED on and off:
void setup() { Â Â Â Â Â Â Â pinMode (led,OUTPUT); }
These functions define the letter S and O to be used in the SOS message:
void S() { Â Â Â Â Â Â Â Â Â Â dot(); Â Â Â Â Â Â Â Â Â Â dot(); Â Â Â Â Â Â &...