Clap-on Lights with Tessel

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:

  • Tessel
  • Ambient Module
  • Relay Module
  • Lights and plug (or similar)

    To use:

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

    See it work:

    On vine

    Step 1: Plug in wires to Relay module

    Clap-on Lights with Tessel
    Clap-on Lights with Tessel

    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

    Clap-on Lights with Tessel

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

    Step 3: Plug in Tessel to USB

    Clap-on Lights with Tessel

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

    Step 4: Plug in power to the lights

    Clap-on Lights with Tessel
    Clap-on Lights with Tessel

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

    Clap-on Lights with Tessel

    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); }); });

  • Clone the repo to get the code on your computer.
  • From inside the directory, `npm install` in the command line to install the ambient and relay module libraries.
  • If you don't have tessel installed already, `npm install tessel -g` so you have the Tessel command line tool.
  • `tessel run index.js` to run the code on your Tessel.
  • 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
  •  
     

    Tag cloud

    make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel