Skip to content

Instantly share code, notes, and snippets.

@daniellevass
Last active Mar 4, 2016
Embed
What would you like to do?
BGL Tech Conference 2016

Imgur

Hello, and welcome!

###Aim:

  • Build your own Thing for the Internet using littleBits in small teams
  • Demonstrate the Thing you've made to everyone
  • Write up how others (read: children) could also build your thing

Why we're doing it

I've spent the past two years teaching kids to code - littleBits are amazing but they're incredibly badly documented. Especially when you get into actually writing real code for it! And there aren't many projects that are interesting for kids to actually build. It would be great if we at BGL could populate a couple of activities kids could follow to help them get started!

Imgur

Max connected three cloudBits to the Bath Hacked pollution data to display real time pollution levels for Bath

littleBits

littleBits are like lego for technology! They are simply colour coded; blue is for power; green is an output, pink is an input; and orange is logic. I have 8 cloudbits (orange) that you can connect to the internet (they need USB power first) - so if we have more people than bits, we'll need to form small groups!

Feel free to take whichever inputs and outputs your interested in - but please only take whatever you're going to use so that everyone may have an opportunity to play!

Cloud Control

The first step to programming the bits is to sign on to the web portal at http://control.littlebitscloud.cc

The username is hello@de-velopment.com and I'll write the password somewhere visible for everyone to see. Note that the buttons for sign up and log in are weird - so be careful which button you push first!

Once you've signed in you should see on the left hand side a list of pokemon names - click on the pokemon that matches the cloudBit you have! If you're stuck check out this page - http://bulbapedia.bulbagarden.net/wiki/Starter_Pok%C3%A9mon

First check that your cloudbit has a little green dot next to the name, this means it's properly connected to the internet! Note that if you select another cloudbit you could affect other people's projects!

Now you should see a massive button in the middle of the page - connect an output to your cloudBit (any green bit) and press the button. You should see something happen! If not, somethings gone wrong and ask me for some help!

Along the bottom you should see a tab for settings - this is where you can find out the device id and access token which will need for the next step!

Imgur

JSFiddle

So now we've established that our bit is connected to the internet. We can look at customising it to make it useful for us!

All we're going to do is send a HTTP Request using the littlebits API. We could do this in a multitude of ways but going back to the original aims - I want to make this easier for kids. Often in schools we're not allowed to install any programs, so we have to depend on web tools such as JSFiddle and JavaScript.

Here's an example of a HTTP Request in JavaScript which requires us to have jQuery.

var token = "xx";
var device ="yy"

$.ajax({
  url: 'http://api-http.littlebitscloud.cc/v2/devices/'+device+'/output',
  type: 'post',
  data: 
    JSON.stringify({
      "percent": 20,
      "duration_ms": 1000
    }),
  headers: {
    'Authorization': 'Bearer ' + token,
    'Content-Type': 'application/json',
  },
  success: function(data) {
    console.log(data);
  },
  err

I already have a JSFiddle example set up - just remember to set the device id and bearer token : http://jsfiddle.net/9hypen62/ - feel free to fork this for your own project.

One of the tasks surrounding making this easier for kids would be a wrapper around the HTTP Request - maybe a method they could call asking for the device id, auth token, percentage, and duration?

Project Ideas

Next, we can then customise the data we're sending based on different inputs, e.g. my favourite API is the USGS for earthquakes. I could set up a cloudBit to display how far an earthquake is from my location (london, england) every time one occurs.

Other proejct ideas:

Imgur

  • Synchronised Christmas decorations - using timing to make different cloudbits light up
  • Internet enabled door bells - connect a button to the cloudbit and there's a slack integration
  • Pet feeder - connect a pressure sensor and log any weight differences - you could find out how often your pet feeds!
  • Baby monitor - listen for any noise via the cloudbit - find out how often your child wakes up over night
  • Internet enabled umbrella stand - use the Yahoo weather API to light up an umbrella if it's due to rain
  • Interactive Charity counter - for Dilip going to Zambia!
  • Your own ideas - everyone should have their own favourite API!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment