Group 7: Track Your Action
Introduction
For our group project we began to discuss our different options and the endless possibilities with Arduino. We wanted to create something that would be of use to the person in their daily life.
So we began to narrow down our options into creating a device that tracks a user’s activity. We looked around at different apps out there such as ‘Pacer’ that tells a user how many steps they take but doesn’t necessarily break down the timings. Therefore, our aim for our project was to create a device that tells the user on a visual interface their level of activity and how long they were walking, standing or sitting for during the day.
Brainstorm
Research
When we had decided our aim for the project we then did some research specifically into the design and functionality of the device. We looked at the current market to see what lacked and how we could produce something that would satisfy the user. Therefore, we concentrated on making the arduino be able to detect the timings of activeness throughout the day onto the serial monitor. We also made sure the design of the visual interface was appealing to the user, since the user would check this daily several times in order to see their progress. Before we went into making the design we looked at several different designs from current apps that are already out there and took the positive factors and discarded what we thought didn’t work. We realised making it minimal and very clear to read was the most important point as the user will just want a simplistic design that is quick and easy to read since they want instant gratification.
Project Plan
We began by meeting often throughout the week to discuss ideas, design the device, and work on the code together. We all were delegated particular tasks at each stage, and met each other when we seeked help.
Please See Below for: November & December gantt chart.
Task List
- Began Discussing Ideas
- Brainstorming Methods & Techniques
- Created Design Interface
- Ordered Components
- Soldering Components
- Began Pseudo Code
- Gathered Components Together
- Made Test Code
- Ran Code & Tested Device
- Fixed Any Errors
Design
This was the design we had worked on to go on the LCD screen and we focused on 3 elements whilst keeping the screen clean and minimal as possible. We had an: activity bar, information and an icon. The activity bar was at the bottom and measured if the user was highly active, inactive or mediocre. The information would tell the user how long they had been in their current action since their last state. The image would further reinforce their state of action to help the user visualise their movement or lack of movement.
Shortcoming
Maker Manual
Components:
- LSM303DLHC Accelerometer
- Force Sensor
- 3x 10k Ohm Resistors
- Wire
- Breadboard
- Arduino UNO Board
Libraries you need:
Adafruit LSM303DLHC
Integrated Code (no screen)-
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_LSM303_U.h>
float X1;
float X2;
float DvalX;
int walk = 0;
int stand = 0;
int walkingtime = 0;
const int FSR_PIN = A0;
int sitTimeAll = 0;
int sitTimeNow = 0;
int leavingTime = 0;
/* Assign a unique ID to this sensor at the same time */
Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(54321);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println(“Accelerometer Test”); Serial.println(“”);
/* Initialise the sensor */
if(!accel.begin())
{
/* There was a problem detecting the ADXL345 … check your connections */
Serial.println(“Ooops, no LSM303 detected … Check your wiring!”);
while(1);
}
pinMode(FSR_PIN, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int fsrADC = analogRead(FSR_PIN);
if(fsrADC !=0){
sittingdetect(fsrADC);
}else if(fsrADC == 0 && leavingTime !=0){
sittingdetect(fsrADC);
}else{
detectXaxis();
Serial.println(“Walking Time:”);Serial.print(walkingtime);Serial.println(“s”);
Serial.println();
}
}
void detectXaxis(){
sensors_event_t event;
accel.getEvent(&event);
X1 = event.acceleration.x;
delay(300);
accel.getEvent(&event);
X2 = event.acceleration.x;
DvalX = X1 – X2;
Serial.println(DvalX);
if(DvalX >= 1.30 || DvalX <= -1.30){
if(stand > 0){
stand–;
}
if(walk >= 0 && walk < 5){
walk++;
}
if(walk < 5 && stand > 0){
Serial.println(“standing”);
Serial.println();
delay(700);
}else if(walk > 0 || stand == 0){
walkingtime++;
Serial.println(“Walking”);
Serial.println();
delay(700);
}
}
if(DvalX <= 1.30 && DvalX >= -1.30){
if(walk > 0){
walk–;
}
if(stand >= 0 && stand < 5){
stand++;
}
if(stand < 5 && walk > 0){
walkingtime++;
Serial.println(“walking”);
Serial.println();
delay(700);
}else if(stand > 0 || walk == 0){
Serial.println(“Standing”);
Serial.println();
delay(700);
}
}
/*Serial.println(DvalX);
Serial.println();
delay(700);*/
}
void sittingdetect(int sitting)
{
if(sitting >=800){
sitTimeAll++;
sitTimeNow++;
leavingTime = 10;
Serial.println(“Sitting”);
Serial.print(“Sitting Time:”);Serial.print(sitTimeNow);Serial.print(” s”);
Serial.println();
if(sitTimeNow >=10){
Serial.print(“Please stand up and move your body.”);
Serial.println();
}
Serial.println();
delay(2000);
}
if(sitting <=800){
leavingTime–;
if(leavingTime > 0){
Serial.println(“Leaving”);
Serial.println();
delay(1000);
}
if(leavingTime <= 0){
Serial.println(“Standing”);
Serial.println();
sitTimeNow = 0;
delay(1000);
}
/*Serial.println(“Standing”);
Serial.println(leavingTime);
Serial.println();
delay(1000);*/
}
}
Integrated Code (with TFT screen)-
Code For Moving Detection
int sitTimeAll = 0;
int sitTimeNow = 0;
int leavingTime = 0;void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(FSR_PIN, INPUT);
}void loop() {
// put your main code here, to run repeatedly:
int fsrADC = analogRead(FSR_PIN);
sittingdetect(fsrADC);
}void sittingdetect(int sitting)
{
if(sitting >=800){
sitTimeAll++;
sitTimeNow++;
leavingTime = 10;
Serial.println(“Sitting”);
Serial.print(“Sitting Time:”);Serial.print(sitTimeNow);Serial.print(” s”);
Serial.println();
if(sitTimeNow >=10){
Serial.print(“Please stand up and move your body.”);
Serial.println();
}
Serial.println();
delay(1000);
}if(sitting <=800){
leavingTime–;
if(leavingTime > 0){
Serial.println(“Leaving”);
Serial.println();
delay(1000);
}
if(leavingTime <= 0){
Serial.println(“Standing”);
Serial.println();
sitTimeNow = 0;
delay(1000);
}
/*Serial.println(“Standing”);
Serial.println(leavingTime);
Serial.println();
delay(1000);*/
}
}