在 FreeBSD 的源码中有一些字符游戏,位置是 /usr/src/games,其中一个是 morse,它可以把字符串翻译成莫尔斯码,也可以把莫尔斯码翻译成字符串。不仅如此,这个程序还可以驱动外部硬件设备,把莫尔斯码发送出去。
在 morse 的 manual page 里有这样一段话:
Using the -d flag, it is possible to key an external device, like a sidetone generator with a headset for training purposes, or even your ham radio transceiver. For the latter, simply connect an NPN transistor to the serial port device, emitter connected to ground, base connected through a resistor (few kiloohms) to RTS, collector to the key line of your transceiver (assuming the transceiver has a positive key supply voltage and is keyed by grounding the key input line). A capacitor (some nanofarads) between base and ground is advisable to keep stray RF away, and to suppress the minor glitch that is generated during program startup.
就是说如果用 -d 选项,程序输出的 Morse 码会出现在串口的 RTS 脚上面,我们可以用一只 LED 来验证。
LED 阳极接串口的第 7 脚 RTS,阴极通过一个 4.7k 的限流电阻接到串口第 5 脚 GND。
LED 按照 Morse 码的节奏闪烁。