让你的RouterBOARD演奏音乐,以及当闹钟!

近日购入一台RB962UiGS-5HacT2HnT(MikroTik hAP AC)。把玩之时我发现它有一个可编程蜂鸣器,可以发出20-20000Hz的声音。既然有这么好的一个功能,我们不妨来好好利用一下嘛。

Bilibili地址(受上传码率限制,质量糟糕)

首先,怎么让它发出一个音呢?命令很简单: :beep frequency=<频率> length=<持续时间(秒)> 。不过要注意:这个命令是异步的,且下一条会立即覆盖上一条。因此,每两个音之间得加一个延迟。

下面是老少咸宜的世界著名歌曲《小星星》的脚本。偷个懒用的十二平均律。

:beep frequency=523 length=0.5
:delay 0.7
:beep frequency=523 length=0.5
:delay 0.7
:beep frequency=783 length=0.5
:delay 0.7
:beep frequency=783 length=0.5
:delay 0.7
:beep frequency=880 length=0.5
:delay 0.7
:beep frequency=880 length=0.5
:delay 0.7
:beep frequency=783 length=1.2
:delay 1.4

:beep frequency=698 length=0.5
:delay 0.7
:beep frequency=698 length=0.5
:delay 0.7
:beep frequency=659 length=0.5
:delay 0.7
:beep frequency=659 length=0.5
:delay 0.7
:beep frequency=587 length=0.5
:delay 0.7
:beep frequency=587 length=0.5
:delay 0.7
:beep frequency=523 length=1.2
:delay 1.4

:beep frequency=783 length=0.5
:delay 0.7
:beep frequency=783 length=0.5
:delay 0.7
:beep frequency=698 length=0.5
:delay 0.7
:beep frequency=698 length=0.5
:delay 0.7
:beep frequency=659 length=0.5
:delay 0.7
:beep frequency=659 length=0.5
:delay 0.7
:beep frequency=587 length=1.2
:delay 1.4

:beep frequency=783 length=0.5
:delay 0.7
:beep frequency=783 length=0.5
:delay 0.7
:beep frequency=698 length=0.5
:delay 0.7
:beep frequency=698 length=0.5
:delay 0.7
:beep frequency=659 length=0.5
:delay 0.7
:beep frequency=659 length=0.5
:delay 0.7
:beep frequency=587 length=1.2
:delay 1.4

:beep frequency=523 length=0.5
:delay 0.7
:beep frequency=523 length=0.5
:delay 0.7
:beep frequency=783 length=0.5
:delay 0.7
:beep frequency=783 length=0.5
:delay 0.7
:beep frequency=880 length=0.5
:delay 0.7
:beep frequency=880 length=0.5
:delay 0.7
:beep frequency=783 length=1.2
:delay 1.4

:beep frequency=698 length=0.5
:delay 0.7
:beep frequency=698 length=0.5
:delay 0.7
:beep frequency=659 length=0.5
:delay 0.7
:beep frequency=659 length=0.5
:delay 0.7
:beep frequency=587 length=0.5
:delay 0.7
:beep frequency=587 length=0.5
:delay 0.7
:beep frequency=523 length=1.2
:delay 1.4

RouterOS WebFig screenshot on Script page
保存时记得加上read权限(如图所示),再点击Run Script按钮就可以听到啦。

那么怎么做闹钟呢?这就要用到Scheduler功能了。举个例子,如果我们想要每天七点响起闹钟的话,就把Start Time设为07:00:00,Interval设为24:00:00。On Event填写刚才保存的脚本名字,同样给read权限。
RouterOS WebFig on new Scheduler page

感觉打开了新世界的大门呢!

4 thoughts on “让你的RouterBOARD演奏音乐,以及当闹钟!

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据