{"id":14068,"date":"2017-06-14T23:21:49","date_gmt":"2017-06-15T03:21:49","guid":{"rendered":"http:\/\/scruss.com\/blog\/?p=14068"},"modified":"2017-06-15T11:59:10","modified_gmt":"2017-06-15T15:59:10","slug":"vm-clap1-%f0%9f%91%8f-sensor-gpiozero-on-raspberry-pi","status":"publish","type":"post","link":"https:\/\/scruss.com\/blog\/2017\/06\/14\/vm-clap1-%f0%9f%91%8f-sensor-gpiozero-on-raspberry-pi\/","title":{"rendered":"VM-CLAP1 \u00f0\u0178\u2018\u008f sensor + gpiozero on Raspberry Pi"},"content":{"rendered":"<p>Well, that was easy!<\/p>\n<p>Since the Verbal Machines <a href=\"https:\/\/elmwoodelectronics.ca\/products\/hand-clap-sensor-vm-clap1\">VM-CLAP1<\/a> sensor is an open collector type \u00e2\u20ac\u201d that is, it sinks current when triggered \u00e2\u20ac\u201d it behaves like a simple <a href=\"https:\/\/gpiozero.readthedocs.io\/en\/stable\/recipes.html#button\">button<\/a> to <a href=\"https:\/\/gpiozero.readthedocs.io\/en\/stable\/\">gpiozero<\/a>, the Raspberry Pi Python GPIO library. If you attach a callback function to the sensor&#8217;s when_pressed event, your Python script will call that function every time it registers a clap.<\/p>\n<p>The wiring is as simple as it could be:<br \/>\n<a href=\"http:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2017\/06\/clap_gpiozero_bb.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-14070\" src=\"http:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2017\/06\/clap_gpiozero_bb.png\" alt=\"\" width=\"951\" height=\"888\" srcset=\"https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2017\/06\/clap_gpiozero_bb.png 951w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2017\/06\/clap_gpiozero_bb-160x149.png 160w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2017\/06\/clap_gpiozero_bb-320x299.png 320w, https:\/\/scruss.com\/wordpress\/wp-content\/uploads\/2017\/06\/clap_gpiozero_bb-768x717.png 768w\" sizes=\"auto, (max-width: 951px) 100vw, 951px\" \/><\/a><\/p>\n<pre> VM-CLAP1: Raspberry Pi:\r\n\u00c2\u00a0========= =============\r\n\u00c2\u00a0     GND \u00e2\u2020\u2019 GND\r\n\u00c2\u00a0     PWR \u00e2\u2020\u2019 3V3\r\n\u00c2\u00a0     OUT \u00e2\u2020\u2019 GPIO 4\r\n<\/pre>\n<p>This example code just prints <strong>clap!<\/strong> when the board picks up a \u00f0\u0178\u2018\u008f:<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n#!\/usr\/bin\/env python3\r\n# -*- coding: utf-8 -*-\r\n\r\n# Raspberry Pi gpiozero test for\r\n# Verbal Machines VM-CLAP1 clap sensor\r\n#   scruss - 2017-06\r\n#\r\n# Wiring:\r\n#\r\n#  VM-CLAP1:    Raspberry Pi:\r\n#  =========    =============\r\n#    GND     \u00e2\u2020\u2019   GND\r\n#    PWR     \u00e2\u2020\u2019   3V3\r\n#    OUT     \u00e2\u2020\u2019   GPIO 4\r\n\r\nfrom gpiozero import Button\r\nfrom signal import pause\r\n\r\ndef clapping():\r\n        print(&quot;clap!&quot;)\r\n\r\nclap = Button(4)\r\nclap.when_pressed = clapping\r\npause()\r\n<\/pre>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Well, that was easy! Since the Verbal Machines VM-CLAP1 sensor is an open collector type \u00e2\u20ac\u201d that is, it sinks current when triggered \u00e2\u20ac\u201d it behaves like a simple button to gpiozero, the Raspberry Pi Python GPIO library. If you attach a callback function to the sensor&#8217;s when_pressed event, your Python script will call that [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[7,2],"tags":[3056,2208,3058,3059,2540,2510],"class_list":["post-14068","post","type-post","status-publish","format-standard","hentry","category-computers-suck","category-goatee-stroking-musing-or-something","tag-clap","tag-electronics","tag-gpio","tag-gpiozero","tag-python","tag-raspberrypi"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pQNZZ-3EU","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/14068","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/comments?post=14068"}],"version-history":[{"count":6,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/14068\/revisions"}],"predecessor-version":[{"id":14075,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/posts\/14068\/revisions\/14075"}],"wp:attachment":[{"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/media?parent=14068"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/categories?post=14068"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scruss.com\/blog\/wp-json\/wp\/v2\/tags?post=14068"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}