Silicon ChipArduino Clap Light - June 2024 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Avoid cheap extension cords!
  4. Feature: Privacy Phones by Dr David Maddison
  5. Subscriptions
  6. Feature: Electronex 2024 by Noel Gray
  7. Project: Self Toggling Relay by Tim Blythman
  8. Project: Arduino Clap Light by Tim Blythman
  9. Project: ESR Test Tweezers by Tim Blythman
  10. Feature: MicroMag3 Magnetic Sensor by Jim Rowe
  11. Project: USB-C Serial Adaptor by Tim Blythman
  12. Project: DC Supply Protectors by John Clarke
  13. Project: WiFi DDS Function Generator, Pt2 by Richard Palmer
  14. Serviceman's Log: Another mixed bag of servicing stories by Various
  15. Circuit Notebook: Arduino bin reminder by Geoff Coppa
  16. Circuit Notebook: Programming a Micromite over Bluetooth by Grant Muir
  17. Vintage Radio: HeathKit GW-21A handheld transceivers by Dr Hugo Holden
  18. PartShop
  19. Market Centre
  20. Advertising Index
  21. Notes & Errata: Skill Tester 9000, April & May 2024
  22. Outer Back Cover

This is only a preview of the June 2024 issue of Silicon Chip.

You can view 57 of the 112 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Articles in this series:
  • Wired Infrared Remote Extender (May 2024)
  • Symbol USB Keyboard (May 2024)
  • Wired Infrared Remote Extender (May 2024)
  • Thermal Fan Controller (May 2024)
  • Symbol USB Keyboard (May 2024)
  • Thermal Fan Controller (May 2024)
  • Self Toggling Relay (June 2024)
  • Self Toggling Relay (June 2024)
  • Arduino Clap Light (June 2024)
  • Arduino Clap Light (June 2024)
  • Lava Lamp Display (July 2024)
  • Digital Compass (July 2024)
  • Digital Compass (July 2024)
  • Lava Lamp Display (July 2024)
  • JMP009 - Stroboscope and Tachometer (August 2024)
  • JMP007 - Ultrasonic Garage Door Notifier (August 2024)
  • JMP009 - Stroboscope and Tachometer (August 2024)
  • JMP007 - Ultrasonic Garage Door Notifier (August 2024)
  • IR Helper (September 2024)
  • IR Helper (September 2024)
  • No-IC Colour Shifter (September 2024)
  • No-IC Colour Shifter (September 2024)
  • JMP012 - WiFi Relay Remote Control (October 2024)
  • JMP012 - WiFi Relay Remote Control (October 2024)
  • JMP015 - Analog Servo Gauge (October 2024)
  • JMP015 - Analog Servo Gauge (October 2024)
  • JMP013 - Digital spirit level (November 2024)
  • JMP013 - Digital spirit level (November 2024)
  • JMP014 - Analog pace clock & stopwatch (November 2024)
  • JMP014 - Analog pace clock & stopwatch (November 2024)
  • WiFi weather logger (December 2024)
  • Automatic night light (December 2024)
  • WiFi weather logger (December 2024)
  • Automatic night light (December 2024)
  • BIG LED clock (January 2025)
  • Gesture-controlled USB lamp (January 2025)
  • Gesture-controlled USB lamp (January 2025)
  • BIG LED clock (January 2025)
  • Transistor tester (February 2025)
  • Wireless flashing LEDs (February 2025)
  • Transistor tester (February 2025)
  • Wireless flashing LEDs (February 2025)
  • Continuity Tester (March 2025)
  • RF Remote Receiver (March 2025)
  • Continuity Tester (March 2025)
  • RF Remote Receiver (March 2025)
  • Discrete 555 timer (April 2025)
  • Weather monitor (April 2025)
  • Discrete 555 timer (April 2025)
  • Weather monitor (April 2025)
Items relevant to "Arduino Clap Light":
  • Arduino firmware for JMP006 - Clap Light (Software, Free)
Articles in this series:
  • Wired Infrared Remote Extender (May 2024)
  • Symbol USB Keyboard (May 2024)
  • Wired Infrared Remote Extender (May 2024)
  • Thermal Fan Controller (May 2024)
  • Symbol USB Keyboard (May 2024)
  • Thermal Fan Controller (May 2024)
  • Self Toggling Relay (June 2024)
  • Self Toggling Relay (June 2024)
  • Arduino Clap Light (June 2024)
  • Arduino Clap Light (June 2024)
  • Lava Lamp Display (July 2024)
  • Digital Compass (July 2024)
  • Digital Compass (July 2024)
  • Lava Lamp Display (July 2024)
  • JMP009 - Stroboscope and Tachometer (August 2024)
  • JMP007 - Ultrasonic Garage Door Notifier (August 2024)
  • JMP009 - Stroboscope and Tachometer (August 2024)
  • JMP007 - Ultrasonic Garage Door Notifier (August 2024)
  • IR Helper (September 2024)
  • IR Helper (September 2024)
  • No-IC Colour Shifter (September 2024)
  • No-IC Colour Shifter (September 2024)
  • JMP012 - WiFi Relay Remote Control (October 2024)
  • JMP012 - WiFi Relay Remote Control (October 2024)
  • JMP015 - Analog Servo Gauge (October 2024)
  • JMP015 - Analog Servo Gauge (October 2024)
  • JMP013 - Digital spirit level (November 2024)
  • JMP013 - Digital spirit level (November 2024)
  • JMP014 - Analog pace clock & stopwatch (November 2024)
  • JMP014 - Analog pace clock & stopwatch (November 2024)
  • WiFi weather logger (December 2024)
  • Automatic night light (December 2024)
  • WiFi weather logger (December 2024)
  • Automatic night light (December 2024)
  • BIG LED clock (January 2025)
  • Gesture-controlled USB lamp (January 2025)
  • Gesture-controlled USB lamp (January 2025)
  • BIG LED clock (January 2025)
  • Transistor tester (February 2025)
  • Wireless flashing LEDs (February 2025)
  • Transistor tester (February 2025)
  • Wireless flashing LEDs (February 2025)
  • Continuity Tester (March 2025)
  • RF Remote Receiver (March 2025)
  • Continuity Tester (March 2025)
  • RF Remote Receiver (March 2025)
  • Discrete 555 timer (April 2025)
  • Weather monitor (April 2025)
  • Discrete 555 timer (April 2025)
  • Weather monitor (April 2025)
Items relevant to "ESR Test Tweezers":
  • ESR Test Tweezers four PCB set (AUD $10.00)
  • Advanced/ESR Test Tweezers back panel PCB (blue) [04105242] (AUD $2.50)
  • PIC24FJ256GA702-I/SS programmed for the ESR Test Tweezers (0410524A.HEX) (Programmed Microcontroller, AUD $15.00)
  • 0.96in white OLED with SSD1306 controller (Component, AUD $10.00)
  • ESR Test Tweezers kit (Component, AUD $50.00)
  • Firmware for the ESR Test Tweezers [0410524A.HEX] (Software, Free)
  • ESR Test Tweezers PCB patterns (PDF download) [04105241-2] (Free)
Items relevant to "MicroMag3 Magnetic Sensor":
  • Sample software for the MicroMag3 3-Axis Magnetic Sensor module (Free)
Items relevant to "USB-C Serial Adaptor":
  • USB-C Serial Adaptor PCB (black) [24106241] (AUD $2.50)
  • USB-C Serial Adaptor PCB (green) [24106241] (AUD $1.00)
  • PIC16F1455-I/SL programmed for the Type-C USB Serial Adaptor [2410624A.HEX] (Programmed Microcontroller, AUD $10.00)
  • USB-C Serial Adaptor full kit (Component, AUD $20.00)
  • Firmware for the USB-C Serial Adaptor [2410624A.HEX] (Software, Free)
  • USB-C Serial Adaptor PCB pattern (PDF download) [24106241] (Free)
Items relevant to "DC Supply Protectors":
  • DC Supply Protector PCB (adjustable SMD version) [08106241] (AUD $2.50)
  • DC Supply Protector PCB (adjustable TH version) [08106242] (AUD $2.50)
  • DC Supply Protector PCB (fixed TH version) [08106243] (AUD $2.50)
  • DC Supply Protector kit (adjustable SMD version) (Component, AUD $17.50)
  • DC Supply Protector kit (adjustable TH version) (Component, AUD $22.50)
  • DC Supply Protector kit (fixed TH version) (Component, AUD $20.00)
  • DC Supply Protector PCB patterns (PDF download) [08106241-3] (Free)
Items relevant to "WiFi DDS Function Generator, Pt2":
  • WiFi DDS Function Generator PCB [04104241] (AUD $10.00)
  • 3.5-inch TFT Touchscreen LCD module with SD card socket (Component, AUD $35.00)
  • Laser-cut pieces for optional WiFi DDS Function Generator stand (PCB, AUD $7.50)
  • Firmware for the WiFi DDS Function Generator (Software, Free)
  • WiFi DDS Function Generator PCB pattern (PDF download) [04104241] (Free)
  • WiFi DDS Function Generator case drilling diagram and labels (Panel Artwork, Free)
Articles in this series:
  • WiFi DDS Function Generator, Pt1 (May 2024)
  • WiFi DDS Function Generator, Pt1 (May 2024)
  • WiFi DDS Function Generator, Pt2 (June 2024)
  • WiFi DDS Function Generator, Pt2 (June 2024)
Items relevant to "Arduino bin reminder":
  • Software for the Arduino-based Bin Reminder (Free)

Purchase a printed copy of this issue for $12.50.

Mini Projects #006 – by Tim Blythman SILICON CHIP Arduino Clap Light Can’t find the remote control? Don’t worry! Clapping lets you switch devices on and off with this simple project. You may have seen it on TV; now you can build it yourself. T he “Clapper” is a sound-activated switch introduced in the USA in the 1980s. It is a box that plugs into a power point and allows two appliances to be connected. According to the motto, “Clap on! Clap off!”, you could simply clap to switch an attached device on or off. It toggled one appliance on or off when two claps were detected. Another appliance would respond to three claps. By some accounts, it could be too sensitive, reacting to other sounds or even people talking. Most people used it to control a light or lamp since they are unlikely to cause harm if switched on or off at the wrong time. This simple project provides a similar function. The Arduino Clap Light Such a device is easy to build using an Arduino Leonardo board and a module capable of detecting sound. To save ourselves from getting too close to mains voltages, we’ve added a 433MHz transmitter to provide remote control of a few different types of radio-controlled devices. This will allow you to control either a wireless power point such as Jaycar’s MS6148, or a commonly installed ceiling fan and light combination (sold under the ‘Brilliant’ brand), which incorporates an RF remote control. In both cases, the circuit transmits the same signal as the remote control, so the existing hand controller can still be used. Since we are providing the Arduino source code, you could adapt it to control another device, such as a relay module or even something simple like a light-emitting diode (LED) connected directly to the Leonardo board. Fig.1 shows the wiring diagram. You can also see how we have laid it out in the photos. We used Blu-Tack to attach the Leonardo to a breadboard, then fitted the modules to the breadboard and connected them with jumper wires. The Leonardo monitors the analog signal from the sound sensor module and then sends a digital signal to the wireless transmitter module at the appropriate time. Since the sound sensor module delivers an analog signal, we must Parts List – Clap Light (JMP006) 1 Arduino Leonardo [Jaycar XC4430] 1 Remote Controlled Mains Outlet (see text for options) [Jaycar MS6148] 1 Microphone Sound Sensor Module [Jaycar XC4438] 1 433MHz Wireless Transmitter Module [Jaycar ZW3100] 1 breadboard with jumper wires [Jaycar PB8819] 1 USB Type-A to micro Type-B cable to suit Leonardo [Jaycar WC7757] siliconchip.com.au Australia's electronics magazine perform some processing to distinguish claps. Scope 1 shows the analog signal presented by the sound sensor module in response to a clap; it is the positive half of the raw audio waveform. The negative half of the waveform is clipped to around 0V by a diode on the module. The Arduino sketch We can’t easily differentiate claps from other short, sharp sounds, such as knocks. Still, you might prefer to make a knocking sound to control it. We are basically trying to detect a sharp increase in volume. To detect claps, we need to smooth out the waveform to get a signal corresponding to volume (rather than instantaneous amplitude). We use ‘exponential smoothing’ because it is straightforward to implement. Adding an RC (resistor and capacitor) low-pass filter circuit would have the same effect, but we can do exponential smoothing in software without adding any parts. We then apply some thresholds to distinguish claps from other sounds. We detect the start of a clap when the smoothed value rises above a certain level and its end when the value falls below a different, lower level. This is called hysteresis and is another way to separate claps in a noisy environment. Once one clap is detected, a timer runs for one second and further claps within that second are counted. Thus, June 2024  49 Scope 1: the raw analog signal from the sound sensor module is the positive half of the audio waveform. It needs to be processed to allow claps to be detected. the software can detect multiple claps in close succession. The Leonardo’s onboard LED is also lit while each clap is detected. Scope 2 shows the Arduino Serial Plotter debugging data. The orange trace is the smoothed volume signal; each peak corresponds to what is seen in Scope 1. The green trace shows the claps being detected, while the yellow spike shows the one-second counter expiring, having detected two claps (indicated by the peak reaching 200 on the vertical scale). Note how the smaller orange peaks are ignored. The other two traces ensure that the plotter maintains a useful range. RF communication Scope 2: the Clap Light produces debugging data that can be displayed on the Arduino Serial Plotter. The green trace shows two claps being detected, while the yellow spike indicates when the processor acts on the claps. Other noises (the smaller orange peaks) are ignored. Wireless remote controls use different digital protocols; we have provided software libraries to encode the desired channel and function. We’ll delve into that a bit later during our setup and testing. The digital RF signals are pretty slow (compared to some digital protocols) and are simply ‘bitbanged’ with timed delays. During the period when the Arduino Leonardo is producing the digital RF transmission signal, it does not monitor or respond to a clap signal, but we don’t think that is a big deal, as you would usually not send a second command until you observed the original one being obeyed. The sketch also takes input on the Serial Monitor, so typing ‘1’ will have the same effect as making one clap, ‘2’ for two claps and so forth; this is handy for testing. We can handle cases up to five claps, since that was about the most we could achieve in one second. It wouldn’t be hard to update the code to deal with more if you wanted to. Construction Fig.1: use this wiring diagram to connect up the components for the Clap Light; the wire colours match the prototype. The wire that only connects at one end is the antenna; its other end can be plugged into an empty row on the breadboard. 50 Silicon Chip Australia's electronics magazine Wind the potentiometer on the sound sensor module fully clockwise; this is the highest gain and thus sensitivity setting. Referring to Fig.1, wire it up to the breadboard and Leonardo, but don’t connect the transmitter module. This will allow us to check the operation of the clap sensor. Connect the Leonardo to a computer and upload the Clap_Light sketch (available from siliconchip. au/Shop/6/418). If you open the serial plotter, you should see something like Scope 2. If the ‘L’ LED on the Leonardo flashes when you are not clapping, siliconchip.com.au Photo 1: we built our prototype on a breadboard with jumper wires, but this design could also be made into a custom shield, perhaps using the Jaycar XC4482 Prototyping Shield. turn the sound sensor module pot anti-clockwise until it settles down. If there is no response to claps, you can turn it clockwise. Find a level such that the LED flashes when you clap but not other times. There is also one LED on the sound sensor module that shows when it is powered, so if it isn’t on, there might be a problem. Other AVR main boards like the Uno, Nano and Mega should work, although we haven’t tested them. With that working, connect the transmitter module as per Fig.1. Note that one end of the ANT wire for the transmitter module plugs into an empty row on the breadboard, so the antenna wire doesn’t float around. Using the Jaycar MS6148 (or similar) wireless outlet requires a pairing step; you can also refer to the instruction manual. Power on the outlet and activate the ON function while its LED is flashing. The default sketch lets you do that using the ‘3’ command on the serial monitor. Then use ‘3’ and ‘4’ to check that the outlet switches on and off as expected. Finally, test the clap response while watching the serial plotter to confirm proper operation. The remote control for the MS6148 can control four separate outlets; the rfPowerPoint.h file shows the #defines you can use to emulate these different controls. You can also refer to the doThreeClaps() function in our sketch; the ppSend­RF() function is designed to work with these outlets. The ‘Brilliant’ fan and light controllers are typically hardwired by an electrician and have a remote control that looks like the one shown in Photo 2. Photo 3 shows the coding DIP switches inside the battery enclosure. You can see that this one is set to binary 0b1001 or 9, which is the channel number used in the sendCommand() function called by the doTwoClaps() function. If your remote control has a different coding, change the function to use that number instead of 9. ► Photo 2: if you have a fan and light with a remote control like this, the Clap Light should work with it. Other functions of the Brilliant remote control are listed in the rfFan.h file. There don’t appear to be distinct off or on functions for the light, but there is a code that will turn both the fan and light off together. Summary and more options The Clap Light is quite accurate, but we found it still occasionally reacted to other sounds. For this reason, we have avoided making it respond to single claps. We recommend you do the same and also be careful not to connect anything that might be dangerous if unexpectedly turned on or off. Some devices have integrated IR receivers, so they could be controlled by adding an IR transmitter. The sketch could easily be adapted to control low-voltage items via a relay module. Adding the Jaycar XC3730 LED Matrix Shield would allow you to add multi-coloured lights to the SC Clap Light. Photo 3: the DIP switches inside the remote control are set to match those in the fan/light, so change the sketch code to match its settings. In our case, ON-OFF-OFF-ON corresponds to binary 1001 or 9 in decimal. According to a sticker on the back, this is a Model No 99999 SII RF Transmitter. siliconchip.com.au Australia's electronics magazine June 2024  51