Secondary Menu

Internet Button: Orientation Sensor

After writing up a lot of tutorials about the Particle Core, it was time I started to write about the particle shields. To start of with I chose the Internet Button. The internet button is a Particle shield which has 11 RGB LEDs, 4 push buttons and a 3 axis acclerometer.

In this tutorial I'll show you how to get started with the internet button and make an Orientation Sensor (gravity senor), which makes use of the on-board acclerometer. In my previous tutorials I have showed you how to get started with the Particle Core which serves as a basics to get started with today's project, so I recommend to try that out first.

So let's get started....

Step 1: Tools and Components

All that you need for this instructable is -

Particle Core

Internet Button

You can also get a photon which is cheaper than the particle core.

Note: The internet button comes with a photon, so you don't have to buy a separate one.

Step 2: Getting Started

If you have followed my previous instructables you already have set up your core and have it connected to the internet.

If you are here first, then you can check the step two of any of the previous instructables in the series for steps on how to get started. The steps involve -

If you have gone through all of these steps, then you are good to proceed to the next step.

Step 3: Hardware

There is no circuit for this instructables as everything you need is mounted on the PCB of the Internet button. The Orientation of the shield is calculating the accelerometer relating and then comparing them to the gravity. And the LEDs glow in an order indicting the current Orientation.

Note: I'm using an older version of the internet button, the newer version has a protective case and a buzzer.

Step 4: Code

The code to be uploaded to core can be found below, it is really simple. Also, feel free to make any modification to the code and leave a comment below if you encounter any error.

If you are using an older version of the internet button (as I am), make sure you change

b.begin();

to

b.begin(1);

#include "InternetButton/InternetButton.h"#include "math.h"

InternetButton b = InternetButton();

void setup() { // Tell b to get everything ready to go
// Use b.begin(1); if you have the original SparkButton, which does not have a buzzer or a plastic enclosure
// to use, just add a '1' between the parentheses in the code below.
b.begin();
}

void loop(){
// Want to figure out which LED is the lowest?
// We've hidden the necessary trigonometry in this function.
int ledPos = b.lowestLed();