Clap-on Lights With Tessel
by SelkeyMoonbeam in Circuits > Microcontrollers
8416 Views, 137 Favorites, 0 Comments
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:
- 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:
Plug in Wires to Relay Module
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.
Plug Modules in to Tessel
Relay gets plugged into Port A; Ambient gets plugged into Port B.
Plug in Tessel to USB
Plug in the Tessel to your computer. This provides power and lets you push code.
Plug in Power to the Lights
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); }); });
- 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