Gerald Schalek
Published © GPL3+

Tack your Gait!

Everyone has a certain Gait-Rythtm! ..influenced by architecture and our surrounding. This Project should Tack your Gait and find yours.

IntermediateShowcase (no instructions)10 hours2,105
Tack your Gait!

Things used in this project

Hardware components

Velostat, Linqstat
×1
SparkFun Bluetooth Modem - BlueSMiRF Silver
SparkFun Bluetooth Modem - BlueSMiRF Silver
×1
Coppertape (narrow)
×1
cork 2mm
×2
Foam rubber 2mm
×1
Felt plate
×1

Software apps and online services

Microsoft Virtual Shields for Arduino
You have to use the "Side-Load"-Funktion because the app in the app-store is not working!

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

circuit diagram

Connection of sensors and Bluetooth-module to arduino

Code

TrackYourGait.ino

Arduino
Program for arduino MKR1000 with Connection over Bluetooth to Windows 10 Phone Lumia 550!
/*
    Copyright(c) Microsoft Open Technologies, Inc. All rights reserved.

    The MIT License(MIT)

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files(the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions :

    The above copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.
*/

// Include the ArduinoJson library, a dependency
#include <ArduinoJson.h>

// VirtualShield is the core of all shields
#include <VirtualShield.h>
// Text is to display text onscreen.
#include <Text.h>

// Geolocator is for GPS use
#include <Geolocator.h>

// Instantiate the shields
VirtualShield shield;
Text screen = Text(shield);
Geolocator gps = Geolocator(shield);

int sensor[4];
int sensorstate[4];
int trigger[4];
int count[4];

// Callback event for GPS events
void gpsEvent(ShieldEvent* shieldEvent)
{
  // If there is a sensor error (errors are negative)... display message
  if (shieldEvent->resultId < 0) {
    screen.printAt(3, "Sensor doesn't exist");
    screen.printAt(4, "or isn't turned on.");
    
    screen.printAt(6, "error: " + String(shieldEvent->resultId));
    return;
  }
  
  String lat = String("Lat: ") + String(gps.Latitude);
  String lon = String("Lon: ") + String(gps.Longitude);
  
  // Print the latitude and longitude to the screen.
  screen.printAt(11, lat);
  screen.printAt(12, lon);
}

void refresh(ShieldEvent* shieldEvent)
{
   // put your refresh code here
   // this runs whenever Bluetooth connects, whenever the shield.begin() executes, or the 'refresh' button is pressed in the app:
   screen.clear();
   screen.printAt(1, "Tack your Gait!");
   screen.printAt(4, "Gait Count:");
   screen.printAt(10, "GeoLocation:");
}

void setup() 
{
   // set up virtual shield events: 
   shield.setOnRefresh(refresh);
   
   // begin the shield communication (also calls refresh()).
   shield.begin(); //assumes 115200 Bluetooth baudrate

   // Connect the events to the shields.
   screen.clear();
   screen.printAt(2, "Basic GPS Lookup");

   // When the GPS retrieves values, call this function: gpsEvent()
   gps.setOnEvent(gpsEvent);
  
   // put your setup code here, to run once:
   trigger[0]=360;
   trigger[1]=200;
   trigger[2]=320;
   trigger[3]=200;
}

long nextMinute = 60000;
int beatBPM[4];

void loop() 
{
   shield.checkSensors();

    // put your main code here, to run repeatedly:
    if (millis() > nextMinute) {
      nextMinute = millis() + 60000;
      for (int x=0; x <=3; x++){
        beatBPM[x]=count[x]/(nextMinute/60000);
        String beatscreen = String("BPM Sensor ") + String(x) + String(": ") + String(beatBPM[x]);
        screen.printAt(x+14, beatscreen);
      }
       
    }
    for (int x=0; x <= 3; x++){  
      sensor[x]=analogRead(x);
      if (sensor[x] > trigger[x] && sensorstate[x]==0)
      {
        count[x]=count[x]+1;
        sensorstate[x]=1;
        // Get the GPS coordinates (send the event to request GPS).
        gps.get();
        String sensorscreen = String("Sensor ") + String(x) + String(": ") + String(count[x]);
        screen.printAt(x+5, sensorscreen);
      }
       if (sensor[x] < trigger[x] && sensorstate[x]==1)
      {
        sensorstate[x]=0;
      } 
    }
}

Credits

Gerald Schalek

Gerald Schalek

4 projects • 5 followers
Computernerd and Musicmaker!

Comments