Hackster is hosting Hackster Holidays, Ep. 5: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 5 on Friday!
Veronica YoungDavid HowardAlfonso Soldevilla
Published © GPL3+

KeyMat

KeyMat is an intelligent workmat for a standing desk that tracks the user's calorie burn over the course of a day.

IntermediateShowcase (no instructions)24 hours2,080

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
EVA Foam
×1
Mesh Sheet
×1
Plywood
×1
Resistor 10k ohm
Resistor 10k ohm
×1
copper tape
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Adafruit NeoPixel Strip
×1

Hand tools and fabrication machines

Bandsaw

Story

Read more

Custom parts and enclosures

KeyMat CAD File

This is the complete assembly of the mat. The format is .igs, so it should import to most CAD software programs.

KeyMat Inventor CAD Files

The 3D model was originally done in AutoDesk Inventor. This is a zip file which contains all the separate files as well as the assembly file.

KeyMat Rendering-1

A Rendering of the CAD model using KeyShot

KeyMat Rendering-2

Another rendering of the CAD model using KeyShot

KeyMat Rendering - Exploded View

An exploded view rendering of the mat. The CAD model was rendered using KeyShot

Schematics

KeyMat System

This general system lays out the important components of the KeyMat. It shows how power and data move along the components of the system in a quick and easy diagram. It includes the 3 by 5 copper tape grid that act as touch sensors; this allows the mat to knows where the person is. This diagram also includes how the system connect the arduino, the computer, the LED lights, and the app.

KeyMat Wiring Diagram

This diagram shows the inputs and outputs for the KeyMat in order to allow for easy recreation.

Code

standing

Java
The processing sketch to ive graphic visualization and take i data on the serial bus.

Needs the processing IDE found at processing.org to run
No preview (download only).

standing

Arduino
Code to upload to arduino nano to light LED strip and send locatio data through serial.

Need to have downloaded the Adafruit pixel libraries
#include <Adafruit_NeoPixel.h>
#include <avr/power.h> // Comment out this line for non-AVR boards (Arduino Due, etc.)

#define PIN 13

int col1[] = {A3, A2, A1};
int col2[] = {A0, 12, 11};
int col3[] = {9, 10, 8};
int col4[] = {5, 6, 7};
int col5[] = {2, 3, 4};

int col1Color = 0;
int col2Color = 0;
int col3Color = 0;
int col4Color = 0;
int col5Color = 0;

//fade speed
int fade = 5;

//which LED in the strip is starting
int start = 13;
//how many LEDs are in each column
int piece = (60-15)/5;
//max intensity of color
int colorMax = 100;

Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);

//array of values to end up through Serial for metric gathering
int count[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

void setup() {

Serial.begin(9600);

for(int i = 0; i < 3; i++)
{
  pinMode(col1[i], INPUT);
  pinMode(col2[i], INPUT);
  pinMode(col3[i], INPUT);
  pinMode(col4[i], INPUT);
  pinMode(col5[i], INPUT);
}


strip.begin();
strip.show();

}

void loop() {
  //conditionals to determine inputs and color responses per columns
  for(int i = 0; i < 3; i++)
  {
      if(digitalRead(col1[i]))
      {
        count[i*5+0]++;
        col1Color+=fade;
      }
      else
      {
        count[i*5+0] = 0;
        if(count[0] == 0 && count[5] == 0 && count[10] == 0)
          if(col1Color > 0)
            col1Color-=fade;
      }

      if(digitalRead(col2[i]))
      {
        count[i*5+1]++;
        col2Color+=fade;
      }
      else
      {
        count[i*5+1] = 0;
        if(count[1] == 0 && count[6] == 0 && count[11] == 0)
          if(col2Color > 0)
            col2Color-=fade;
      }
     
      if(digitalRead(col3[i]))
      {
        count[i*5+2]++;
        col3Color+= fade;
      }
      else
      {
        count[i*5+2] = 0;
        if(count[2] == 0 && count[7] == 0 && count[12] == 0)
          if(col3Color > 0)
            col3Color-=fade;
      }
        
      if(digitalRead(col4[i]))
      {
        count[i*5+3]++;
        col4Color+=fade;
      }
      else
      {
        count[i*5+3] = 0;
        if(count[3] == 0 && count[8] == 0 && count[13] == 0)
          if(col4Color > 0)
            col4Color-=fade;
      }
        
      if(digitalRead(col5[i]))
      {
        count[i*5+4]++;
        col5Color+=fade;
      }
      else
      {
        count[i*5+4] = 0;
        if(count[4] == 0 && count[9] == 0 && count[14] == 0)
          if(col5Color > 0)
            col5Color-=fade;
      }
  }
  //edge checking
  if(col1Color>colorMax*2)
    col1Color = colorMax*2;
  if(col2Color>colorMax*2)
    col2Color = colorMax*2;
  if(col3Color>colorMax*2)
    col3Color = colorMax*2;
  if(col4Color>colorMax*2)
    col4Color = colorMax*2;
  if(col5Color>colorMax*2)
    col5Color = colorMax*2;

   //changing the colors based on how long the colors have beeen on
   for(int j = 0; j < piece; j++)
   {
    if(col1Color < colorMax)
     strip.setPixelColor(0*piece+j+start, strip.Color(col1Color, colorMax, 0));
    else
     strip.setPixelColor(0*piece+j+start, strip.Color(colorMax, colorMax, col1Color-colorMax));
    if(col2Color < colorMax)
     strip.setPixelColor(1*piece+j+start, strip.Color(col2Color, colorMax,0));
    else
     strip.setPixelColor(1*piece+j+start, strip.Color(colorMax, colorMax, col2Color-colorMax));
    if(col3Color < colorMax)
     strip.setPixelColor(2*piece+j+start, strip.Color(col3Color, colorMax,0));
    else
     strip.setPixelColor(2*piece+j+start, strip.Color(colorMax, colorMax, col3Color-colorMax));
    if(col4Color < colorMax)
     strip.setPixelColor(3*piece+j+start, strip.Color(col4Color, colorMax,0));
    else
     strip.setPixelColor(3*piece+j+start, strip.Color(colorMax, colorMax, col4Color-colorMax));
    if(col5Color < colorMax)
     strip.setPixelColor(4*piece+j+start, strip.Color(col5Color, colorMax,0));
    else
     strip.setPixelColor(4*piece+j+start, strip.Color(colorMax, colorMax, col5Color-colorMax));
    
    strip.show();

   }
   if(col5Color < colorMax)
     strip.setPixelColor(58, strip.Color(col5Color, colorMax,0));
   else
     strip.setPixelColor(58, strip.Color(colorMax, colorMax, col5Color-colorMax));
    
   strip.show();
  
  for(int i = 0; i < 3; i++)
  {
    Serial.print(count[i*5+0]);
    Serial.print(" ");
    Serial.print(count[i*5+1]);
    Serial.print(" ");
    Serial.print(count[i*5+2]);
    Serial.print(" ");
    Serial.print(count[i*5+3]);
    Serial.print(" ");
    Serial.print(count[i*5+4]);
    Serial.print(" ");

  }

  Serial.println();
  delay(100);
  

}

Credits

Veronica Young

Veronica Young

1 project • 0 followers
David Howard

David Howard

1 project • 0 followers
Alfonso Soldevilla

Alfonso Soldevilla

1 project • 0 followers

Comments