Controlling Lights with Hand Claps

Controlling Lights with Hand Claps

por Citilab Edutec

Boards
Placas:

Citilab ED1

Component/s
Componentes:

Micrófono
This activity is part of the Citilab Course. Check it out!

Controlling lights with hand claps

Boards Some boards have a built-in microphone: micro:bit V2, micro:STEAMakers, M5Stack-Core2 and others. For the Citilab ED1 and others you need to connect a microphone.

Detecting clap count

  • With the Sensing→Microphone library it is possible to detect the number of times one claps their hands.

  • This detection allows us to activate any element of the home display, for example the lighting.

  • For Citilab ED1 and other borads the microphone is connected to the analog input A1.

Analog microphone at A1

The block to use it's clap count. It's important not to have other sounds that might interfere with detection.

Clapping and Lights example

Activate the lights

  • To simulate different lighting levels we can use leds, neopixels or the screen.

  • We can use the fill display with _ block that we will find in the Graphics and Displays→Turtle library instead of draw rectangle ... from the TFT library.

Turtle library

Comparison of fill screen and draw rectangle

Challenge 1: Build a program with different lighting levels controlled by clapping your hands.

Challenge

Solution to challenge 1

Solution challenge 1

Plates For boards with LED screen that allows color change (Citilab ED1, micro:STEAMakers, M5Stack-Core and others) we can define a new block, using the advanced block set display color _.

Omple pantalla LED

CC-BY-SA

© por Citilab Edutec 2019-2022.
Este trabajo tiene una licencia CC-BY-SA 4.0.