loading
Picture of Clap-on Lights with Tessel

Tessel-Clap-Switch

Tessel listens for a clap, then toggles a relay to turn something on and off.

(Also view this project/get the code easily at the Tessel projects page)

You need:

To use:

  1. Clone this repo
  2. npm install
  3. Connect lights to Relay Module in Relay port 1
  4. Plug in modules to Tessel: Relay in port A; Ambient in port B
  5. Plug in tessel via USB
  6. Plug in power to lights/relay
  7. Run "tessel run index.js" from this folder in your terminal
  8. Clap! Watch the lights turn on and off.

See it work:

On vine

 
Remove these adsRemove these ads by Signing Up

Step 1: Plug in wires to Relay module

Picture of Plug in wires to Relay module
IMG_8342.JPG

A relay acts as a switch– either connecting ('on') or not connecting ('off') the two wires fed into the channel.

Use a pen or a nail to press down on the top of the relay, and feed in the red (power) wire.

The ground wire doesn't go into the relay; it just goes straight to the power adapter.

Step 2: Plug modules in to Tessel

Picture of Plug modules in to Tessel

Relay gets plugged into Port A; Ambient gets plugged into Port B.

Step 3: Plug in Tessel to USB

Picture of Plug in Tessel to USB

Plug in the Tessel to your computer. This provides power and lets you push code.

Step 4: Plug in power to the lights

Picture of Plug in power to the lights
IMG_8346.JPG

Step 5: Push code and clap on, clap off!

Picture of Push code and clap on, clap off!

You can download my code from https://github.com/Frijol/Tessel-Clap-Switch. It looks like this:

// Takes a triggering value for ambient sound,
// toggles relay 1 when that trigger is hit.

var tessel = require('tessel'); var relay = require('relay-mono').use(tessel.port['A']); var ambient = require('ambient-attx4').use(tessel.port['B']);

// Sound level (0-1) needed to trigger. You may need to adjust this. var triggerVal = 0.22;

// When the module is connected ambient.on('ready', function () { // Set the sound trigger ambient.setSoundTrigger(triggerVal);

// When the sound trigger is reached ambient.on('sound-trigger', function triggerHit() { // Toggle the switch relay.toggle(1); }); });

  1. Clone the repo to get the code on your computer.
  2. From inside the directory, `npm install` in the command line to install the ambient and relay module libraries.
  3. If you don't have tessel installed already, `npm install tessel -g` so you have the Tessel command line tool.
  4. `tessel run index.js` to run the code on your Tessel.
  5. Clap! Watch the lights turn on and off.

Demo:

If you want to use it separately from your computer, you can run `tessel push index.js` and it will save the code in memory.

You can then disconnect Tessel from your computer, and power Tessel using any of the methods listed here. I plug it into the wall using my Android charger.

As soon as you provide power, Tessel will automatically run your code.

There are a lot of other things I could (trivially) do with this setup but haven't gotten around to:

  • Hook it up to a web interface so I can turn the lights on and off from anywhere with internet
  • Read ambient light data and automatically turn the lights on and off if it's dark/bright in the room
Verticees1 year ago

awesome!

Carleyy1 year ago

Cool! Have you used this in any larger projects?

SelkeyMoonbeam (author)  Carleyy1 year ago

Not the lights. I've been playing around with electrodes + Tessel lately: https://github.com/Frijol/Tessel-GPIO-EMG