Free Domestic Shipping on Orders Over $100!

VM-CLAP1 ๐Ÿ‘ sensor + gpiozero on Raspberry Pi

by Stewart Russell June 19, 2017

Last week I wrote about how easy itย was to interface the Verbal Machines VM-CLAP1 sensor toย an Arduino:ย Clap on ๐Ÿ‘๐Ÿ‘, Clap off ๐Ÿ‘๐Ÿ‘ . This week, I thought I'd show you how to use it with a Raspberry Pi.

Since the sensor is an open collector type โ€” that is, it sinks current when triggered โ€” it behaves like a simple button to gpiozero, the Raspberry Pi Python GPIO library. If you attach a callback function to the sensorโ€™s when_pressed event, your Python script will call that function every time it registers a clap.

The wiring is as simple as it could be:

 VM-CLAP1: Raspberry Pi:
 ========= =============
      GND โ†’ GND
      PWR โ†’ 3V3
      OUT โ†’ GPIO 4

This example code just prints clap! when the board picks up a ๐Ÿ‘:

ย 

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
 
# Raspberry Pi gpiozero test for
# Verbal Machines VM-CLAP1 clap sensor
#   scruss - 2017-06
#
# Wiring:
#
#  VM-CLAP1:    Raspberry Pi:
#  =========    =============
#    GND     โ†’   GND
#    PWR     โ†’   3V3
#    OUT     โ†’   GPIO 4
 
from gpiozero import Button
from signal import pause
 
def clapping():
        print("clap!")
 
clap = Button(4)
clap.when_pressed = clapping
pause()

ย 

This is a trivial example, but at least it shows that anything you can do with a button, you can also do with this hand-clap sensor.

(This article first appeared on the author's personal blog.)




Stewart Russell
Stewart Russell

Author


Leave a comment

Comments will be approved before showing up.


Also in News

Our new location

by Craig L August 10, 2017

Continue Reading

Lower International Shipping Rates!

by Craig L June 14, 2017

Continue Reading

Escape Room Part 5: Final Reflections
Escape Room Part 5: Final Reflections

by Jack Frey May 11, 2017

Continue Reading