See more information and details on the homepage: tessel.io

Websocket example in JavaScript:

/* ambient.js example */
// this example streams sound data from
// the ambient sensor every 0.5 seconds
var tessel = require('tessel');
var ambientlib = require('ambient-attx4');
var WebSocket = require('ws');

// Connect to our ambient sensor.
var ambient = ambientlib.use(tessel.port['A']);

// Open a websocket to our app.
var ws = new WebSocket('ws://awesome-app.com/ambient');
// When the connection is established
ws.on('open', function () {
  setInterval(function () {
    // read some sound level data
    ambient.getSoundLevel(function(err, sdata) {
      if (err) throw err;
      sdata.pipe(ws);
    })
  }, 500); // The readings will happen every .5 seconds 
});
Websocket example in Python:
## ambient.py example
import tessel
import ambient_attx4

port = tessel.port('a')
ambient = ambient_attx4.Ambient(port)

for sound_level in ambient:
    print "Sound: {}".format(sound_level)
Websocket example in Rust:
/* ambient.rs example */
extern crate tessel;
extern crate ambient_attx4;

fn main() {
    let port = tessel::port("a").unwrap();
    let mut ambient = ambient_attx4::Ambient::new(&port).unwrap();

    loop {
        let sound_level = ambient.sound_level().unwrap();
        println!("Sound: {}", sound_level);
    }
}

Clap-activated camera example in JavaScript:

/* ambient-camera.js example */
// this example records video from a camera
// when a certain sound level is reached
var tessel = require('tessel');
var http = require('http');
// set up camera
var cameralib = require('camera-usb');
// set up ambient sensor on port A
var ambient = require('ambient-attx4').use(tessel.port['A']);

// set a sound trigger
ambient.setSoundTrigger(0.6);

cameralib.find(function(camera) {
  // stream some video when sound is sensed
  ambient.on('sound-trigger', function(){
    var req = http.request({
      hostname: 'example.com',
        path: '/upload',
        method: 'POST'
      },
      function (res) {
        res.pipe(process.stdout)
      });
    camera.captureStream(2000, 'mjpg').pipe(req);
  });
});

Clap-activated camera example in Python:

## ambient_camera.py example
import camera_usb
import requests
import tessel
import ambient_attx4

ambient = ambient_attx4.Ambient(tessel.port('a'))
camera = camera_usb.find()

while True:
  ambient.wait_for_sound_trigger(0.6)
  video = camera.capture_stream(500, "mjpg")
  requests.post('http://example.com/upload', data=video)

Clap-activated camera example in Rust:

/* ambient_camera.rs example */
extern crate hyper;
extern crate camera_usb;
extern crate tessel;
extern crate ambient_attx4;


fn main() {
    let mut camera = camera_usb::find().expect("Could not find camera");

    let port = tessel::port("a").unwrap();
    let mut ambient = ambient_attx4::Ambient::new(&port).unwrap();
    let mut client = hyper::Client::new();

    loop {
      ambient.wait_for_sound_trigger(0.6);
      let mut video = camera.capture_stream(2000, camera_usb::Format::MJPG);
      let mut res = client.post("http://example.com/upload")
          .body(&mut video).send().unwrap();
    }
}