電子工作83 – 音声スイッチ

Electronics Project 83 – Sound Activated Switch


概要    Introduction



This device is a sound activated switch, which can detect the human voice and the sound from the speaker of tablet or smartphone, etc. and activate a solid-state relay (SSR) for turning on the room light or other electrical appliances.


回路図   Circuit Diagram

下図 (Fig. 1) で、マイクからの信号は2個のトランジスタ2SC1815からなる増幅回路で増幅され大小の正弦波が発生する。これをバッファーTC4050BPに通すと整形されてきれいな矩形波になりマイクロプロセッサー12F629に入る。この中でほぼ正確に0Vか5Vに変化する矩形波を捉え、SSRをONにしAC100VのLED電球などをONにする。


In Fig. 1, the signal from the microphone is amplified with two transistors (2SC1815) and the resulting signal is then transferred into buffer IC TC4050BP with which  the waveform becomes a clean square wave with its low-level voltage being 0V and its high-level voltage 5V, which can be easily treated by software in PIC 12F629, eventually activating the SSR for turning on AC100V LED lamp and others.



(Photo 1) 完成した音声スイッチ本体

Completed Sound Activated Switch built in aluminum box (size: 150x100x60mm)


(Fig. 2)




 Fig. 2 (A) shows a typical sine-waveform when the microphone picks up my voice "aah-, aah-, ..."and measured at Pin 3 of TC4050 by oscilloscope. Note the low-level voltage is about 0.7V, which may be interpreted as High instead of Low by 12F629. Meanwhile. Fig. 2 (B) shows a clear square-waveform that is measured at Pin 2 of TC4050 when the similar voice is picked up by the microphone. It can be noticed that with the help of TC4050 the low-level voltage becomes almost 0V and the high-level one 5V, which is readily treatable within 12F629.    


Fig. 2 (A)


Fig. 2 (B)






1)    家に置いてあるタブレットに外出先からSkypeでアクセスして、そのスピーカー音で部屋のライトを点灯しようというのが目的だった。

2)    音声をマイクで拾いアンプで増幅した波形は乱れた大小混在する正弦波で、おまけにベースが0.7Vなので、12F629を使ってプログラム処理するには適さない。それがTC4050を通すと綺麗な矩形波になり、12F629の中でプログラム処理するのに適すようになる。

3)    回路図の中でVR100K(15回転)が使われているが、スクリューを反時計回り方向にほぼいっぱいに回すと、SSRが常時ONの状態になりLED(G)が点灯し続ける。したがって、スクリューを反対方向(時計回り)に回して感度を下げてやる必要がある。反時計回り方向いっぱいの位置から時計回り方向に7−8回回した位がちょうど良いようだ。このVRの回転に対する音声スイッチのON/OFFT感度はあまり変わらなかった。

4)    音声だけではなく、マイクの正面を指で軽くタップしても音声スイッチが入ることも分かった。このこと何か別の目的に使えそう

5)    費用は全部で2000円以下。

Results and Comments

1)      This device works well. It is interesting to find that the device not only responds to the voice or sound, but also the light finger tapping on the frontal part of microphone.

2)      Buffer IC TC4050 is a key component.

3)     The total cost is less than 2000 Yen.






In this program, the H-pulse detection routine waits for the arrival of a wide H-pulse. When the routine detects the first H-pulse and then detects the second H-pulse 50 microseconds later, the program judges that the detected pulse is a wide H-pulse generated by voice, activating SSR for 15 minutes. Then, the flow of the program routine returns to the top of the H-pulse detection routine.


'SoundSWRoomMonitor.bas  2015.10.24

'Used to detect the sound from a tablet or smartphone and turn on the room light

'Using 12F629 and PicBasic Pro V2.50A

'******** Pin connection *****************

'Pin 1: Vdd (5.0V)

'Pin 8: Vss (GND)

'Pin 7: GPIO.0: output - connected to SSR to drive a lamp

'Pin 6: GPIO.1: - NC

'Pin 5: GPIO.2: - NC

'Pin 4: GPIO.3: input - Reset - connected to Vdd via R=4.7K                      

'Pin 3: GPIO.4: - NC

'Pin 2: GPIO 5: input - connected to the sound generator circuit

'********** Program ***************


SSR    VAR     GPIO.0  'Driving SSR

SoundPlsIN var GPIO.5  'Read a change of SoundPulse from L to H

CMCON=7             'Disable Comparator

TRISIO=%101000      'GPIO.3,5 - inputs, all others - outputs

I var Byte  '<256



HpeakSearch:   'Waiting the arrival of H-peak while checking H-peak twice

If SoundPlsIN=1 Then

Pauseus 50   'wait 50 us


Goto HpeakSearch


If SoundPlsIN=1 Then  '2nd H-peak checking

Goto SSRTimer


Goto HpeakSearch





High SSR  'SSR -> ON

For I=1 to 30  'Nearly 15-minutes timer

Pause 30000  '30 sec

Next I

Low SSR  'SSR -> OFF


Goto Top



'****** End of program*******


   'melabs U2 Programmer's configurations for 12F629:

   'Oscillator - INTOSC; WDTE - Enable; PWRTE - Disable

   'MCLR - Reset ; BODEN - Enable; Code - Disable; Data EEPROM - Disable.



Menu Pageへ戻る