Introduction: Spark Core Pushup Counter

Picture of Spark Core Pushup Counter

This simple project is part of the instructables build night, hosted during dorkbot.de Aachen in November 2014.

Attach a Spark Core with a Spark Internet button to your body and make sure that the device touches the ground when you do your pushups. The pushup count is displayed on the LEDs of the Internet button. Every single count is registered at data.sparkfun.com

You can see all counts at this URL:

http://data.sparkfun.com/pushups

Step 1: Connect Spark Internet Button and Setup Your Spark Core Board

Put the Spark Core board on your Spark Internet Button shield.

Connect the Spark Core board via USB to your laptop and hold the MODE button for three seconds, until it blinks blue.

Open a serial terminal application (e.g. CoolTerm on a Mac) and enter the single letter i into the serial terminal. The Spark Core tells his ID.

Enter the single letter w into the serial terminal. Follow the instructions to setup your wifi connection.

Open a browser and open the Spark Web IDE at spark.io. Create an account there and log in.

Claim your Spark Core in the Web IDE.

Step 2: Enter Source Code

Create a new app at the Spar IDE and copy and paste the following code to it and flash it to your Spark Core.

#include "SparkButton/SparkButton.h"
#include "phant/phant.h" #include "math.h"

Phant::Stream stream1("data.sparkfun.com", "o8Olg5njd9U1Znnq65wX", "yznqKow82pCAYGGyvBE6", 80, PHANT_POST_METHOD); SparkButton b = SparkButton();

int counter = 0; int value = 0; volatile bool SEND_DATA = false;

void setup() { b.begin(); attachInterrupt(D1, prepareSendData, FALLING); attachInterrupt(D2, prepareSendData, FALLING); attachInterrupt(D3, prepareSendData, FALLING); attachInterrupt(D4, prepareSendData, FALLING); }

void loop() { if(SEND_DATA) { b.allLedsOn(200,200,200); sendDataToSparkfun(); SEND_DATA = false; b.allLedsOff(); b.ledOn(counter,200,0,0); if(counter < 11) { counter++; } } }

void prepareSendData() { if(!SEND_DATA) { value = digitalRead(D1)<<3 | digitalRead(D2)<<2 | digitalRead(D3)<<1 | digitalRead(D4); SEND_DATA = true; } }

void sendDataToSparkfun() { stream1.add("sparkid",Spark.deviceID()); stream1.add("value",value); stream1.sendData(); }

Step 3: Hit the Button

Picture of Hit the Button

If you hit any button, all LEDs will light up and the data will be sent to data.sparkfun.com

Step 4: Counting...

Picture of Counting...

The current count is displayed on the LEDs. Please don't do more than 11 pushups, since the internet button has a limited amount of LEDs ;)

Comments

seamster (author)2014-11-19

I laughed at the number limit. But then I cried, when I remembered that I still probably couldn't reach it...