Category: Assignment-08

Pinwheel

Intended to use rotational speed on pinwheel to measure wind speed by converting angular velocity of the pinwheel to linear velocity. Looking back, I’m not sure how accurate this way of measuring wind speed is, considering properties of the pinwheel (such as friction).

Angular velocity is calculated by using a photocell to detect when a blade of the pinwheel passes over.

What it looks like:

My beautiful picture

A simple demo video that shows it working:

Fritzing board:
pinwheel_bb

Code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include <wire .h>
 
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
 
Adafruit_7segment matrix = Adafruit_7segment();
 
int historyLength = 100;
float sensorHistory[100];
 
float runningL;
float runningMaxL;
float runningMinL;
 
float threshhold;
boolean covered;
 
int speedHistLen = 400;
float speedHistory[400];
 
// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
 
  matrix.begin(0x70);
 
  for (int i=0; i<historylength ; i++) {
    sensorHistory[i] = 0;
  }
 
  for (int j=0; j<speedHistLen; j++) {
    speedHistory[j] = 0;
  }
 
  threshhold = 0.75;
  covered = false;
 
}
 
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  float currL = (float)sensorValue;
 
  for (int i=historyLength; i>0; i-- ){
    sensorHistory[i] = sensorHistory[i-1];
  }
  sensorHistory[0] = sensorValue;
 
  float currMax = -9999;
  float currMin = 9999;
  for (int i=0; i</historylength><historylength ; i++) {
    float ith = sensorHistory[i];
 
    if (ith>currMax) { currMax = ith; }
    if (ith<currmin ) { currMin = ith; }
  }
 
  float A = 0.96;
  float B = 1.0-A;
  runningL = A*runningL + B*currL;
  runningMinL = A*runningMinL + B*currMin;
  runningMaxL = A*runningMaxL + B*currMax;
 
  float currRange = runningMaxL - runningMinL; 
  float halfRange = currRange/2;
 
  unsigned long currMillis = millis();
 
  if (currRange>15.0) {
    if (!covered && currL< (runningL-threshhold*halfRange)) {
      //If sensor is NOT covered and current sensor value falls below threshhold,
      //then a blade is currently passing over
      updateLinearSpeed(0);
      covered = true;
    }
    else if (covered && currL>(runningL+threshhold*halfRange)) {
      //If sensor IS covered and current sensor value falls above threshhold,
      //then a blade just passed over, so update speed
      updateLinearSpeed(1);
      covered = false;
    }
    else {
      updateLinearSpeed(0);
    }
  }
 
  delay(1);
}
 
 
int nBlades = 8;
float radius = 0.085; //in meters
 
 
void updateLinearSpeed(int n) {
  int totalPasses = 0;
  for (int i=speedHistLen-1; i>0; i-- ){
    speedHistory[i] = speedHistory[i-1];
    totalPasses+=speedHistory[i];
  }
  speedHistory[0] = n;
  totalPasses+=n;
 
  float spinSpeed = 2.0*PI/nBlades*radius*((float)totalPasses)/((float)speedHistLen);
  Serial.println(spinSpeed);
 
  int displayed = (int)spinSpeed*100;
 
  int tens = displayed/1000;
  int ones = (displayed/100)%10;
  int tenths = (displayed/10)%10;
  int hundredths = displayed%10;
 
  matrix.writeDigitNum(0,tens,false);
  matrix.writeDigitNum(1,ones,true);
  matrix.drawColon(false);
  matrix.writeDigitNum(3,tenths,false);
  matrix.writeDigitNum(4,hundredths,false);
 
  matrix.writeDisplay();
 
}
</currmin></historylength></wire>

Sitting Above [Adam & Miles]

Sitting Above from adambd on Vimeo.

Screen Shot 2013-11-19 at 1.18.17 PM

Sitting Above is a dynamic sign that displays an estimate of the number of people currently flying overhead. We were interested in bringing attention to the fact that people are always above us. Commercial air travel, once a remarkable feat, has become a necessary and even “inconvenient” reality. In keeping with our low expectations for air travel, Sitting Above uses the alienating visual language of street signs.

We experimented with two modes of representation: kinetic and numerical. We had considered visualizing the biomass of people above using automatically blown bubbles – but were discouraged by the scarcity of helium gas (not to mention the questionable ethics of using helium).

moredata
When Wolfram is unable to provide flight operations data for an airline, we resort to random numbers (between 150-200).

The sign uses a Wixel to communicate wirelessly with a laptop. A Python program queries WolframAlpha for a list of planes above, then asks Wolfram for the average number of people on a given airline. The sum total of these figures is sent to Sitting Above, which shows the value on a seven-segment display.

mannsh
“It’s only powers of primes I think.” – man outside Newell Simon Hall
goodshot
“Paul! There’s some kind of device.” – Police officer

Python program

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import wolframalpha
import time
import random
import serial
 
ser = serial.Serial('/dev/cu.usbmodemfa131', 9600)
 
def testQuery():
    client = wolframalpha.Client('X55U4H-PQ459QE3U4')
    res = client.query('planes overhead')
    output = next(res.results).text
    lines = output.splitlines()
    planes = []
    for line in lines:
        if(line[0] != '(' and line[0] != '|' and line[0] != ' '
           and 'flight' in line):
            endName = line.index('flight')
            planeString = str(line[:endName]) + 'flight operations data'
            if(planeString not in planes): 
                planes += [planeString]
    print 'Number of planes: %s' % len(planes)
    totalPeople = 0
    for plane in planes:
        #print 'trying %s' % (plane)
        planeResults = client.query(plane)
        planeInfo = next(planeResults.results).text
        planeData = planeInfo.splitlines()
        perFlightLine = [l for l in planeData if('average per flight' in l)]
        if(perFlightLine != []):
            start = len('average per flight | ')
            end = perFlightLine[0].find('people')
            perFlight = perFlightLine[0][start:end]
            totalPeople += int(eval(perFlight))
            print 'Per flight for %s: %s' %  (plane,perFlight)
        else:
            randPeople = random.randint(150,200)
            #print randPeople
            totalPeople += randPeople
            print 'Rand people: %s' % randPeople 
    digit = 1
    print totalPeople
    for i in xrange(4):
        ser.write(str((totalPeople/digit) % 10))  
        digit *= 10
 
while True:
    testQuery()
    updateTime = random.randint(30,120)
    time.sleep(updateTime)

Arduino sketch

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include 
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
int number = 0;
int digit = 1;  
 
Adafruit_7segment matrix = Adafruit_7segment();
 
void setup() {
  matrix.begin(0x70);
  Serial.begin(9600);
}
 
void loop() {
  if(Serial.available()) {
    if(digit == 1) number = 0;
    number += (int(Serial.read()) - int('0'))*digit;
    digit *= 10;
    if(digit == 10000) digit = 1;
    Serial.println(number);
  }
  matrix.writeDigitNum(4, number % 10);
  matrix.writeDigitNum(3, (number/10) % 10);
  matrix.writeDigitNum(1, (number/100) % 10);
  matrix.writeDigitNum(0, (number/1000) % 10);
  matrix.writeDisplay();
 
}

Weight in Greed (Ralph + Maryyann)

Have you ever patiently stood in a Buffet line, waiting for your turn to grab some food? Finally, you reach the start of the table and pick up a plate, but you suddenly realize that the previous person had taken such  large portions that the rest of the hungry customers don’t have enough to eat.

People always say to be more conservative or watch our weight. But we never take the time to recognize how much we actually take when we serve ourselves. “Weight in Greed” is based on the idea of bringing awareness to that issue. The most difficult and most important part of our project was actually building the scale to measure the difference in weight. After many attempts, we finally created a wooden scale consisting of a force sensitive resistor, a rounded screw, a few pieces of hardboard, and of course an arduino. The round wooden table, as seen in the video holds a pillar which presses against the force sensitive resistor underneath. Whenever the weight changed, the force applied onto the sensor would change and the difference would flash before readjusting to inform the next customer.

IMG_2980

IMG_2986

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include  // Enable this line if using Arduino Uno, Mega, etc.
//#include  // Enable this line if using Adafruit Trinket, Gemma, etc.
 
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
 
Adafruit_7segment matrix = Adafruit_7segment();
const int pressurePin = 3;
int prevPressureLevel = 5;
 
void setup()
{
#ifndef __AVR_ATtiny85__
  Serial.begin(9600);
  Serial.println("7 Segment Backpack Test");
#endif
  matrix.begin(0x70);
}
 
void loop()
{
  int pressureLevel;
  pressureLevel = analogRead(pressurePin); 
  boolean drawDots = false;
  int ledDisplay = 0;
 
  if (abs(pressureLevel - prevPressureLevel) &gt; 15){
    delay(3000);
    ledDisplay = abs(prevPressureLevel - analogRead(pressurePin));
    Serial.println("hi"+ledDisplay);
  }
 
  matrix.writeDigitNum(0, (ledDisplay / 1000), drawDots);
  matrix.writeDigitNum(1, (ledDisplay / 100) % 10, drawDots);
  matrix.writeDigitNum(3, (ledDisplay / 10) % 10, drawDots);
  matrix.writeDigitNum(4, ledDisplay % 10, drawDots);
 
  matrix.writeDisplay();
  //  Serial.print("sensor: ");
  //  Serial.println(pressureLevel);
  prevPressureLevel = pressureLevel;
  Serial.println(pressureLevel);
  delay(200);
}
}

 

Written by Comments Off on Weight in Greed (Ralph + Maryyann) Posted in Assignment-08

the search for silence

Last week I kept getting angry at the mere presence of more than five people and the constant noise around me. So much so in fact that one of the first ideas for this project I came up with was making what is essentially a punching bag to vent my frustrations on, with the matrix recording the level of my anger. But as I brainstormed over the course of several days, I realized what I was looking for was a sort of tranquility and its unattainable nature. I ended up sketching a fiction where I would travel while carrying around a haphazardly constructed measuring box that could indicate if the location is completely silent/tranquil. In the measuring system of tranquility, the numbers would range from -10 to 0, -10 being the least tranquil and 0 being the complete silence.

20131118_195326

I had followed the extremely well-documented steps by Amanda Ghassaei to create the sound input device, which surprisingly was not trivial as Golan explained to me. I realized belatedly that for my purposes of recognizing “sound” and not “sound pressure,” it would’ve been better to buy a shield instead (and Paolo Pedercini told me after I had assembled the circuit that the ArtFab had recently stocked up on microphone sound detection sensors). But I also realized afterwards that this was fine because it fits the narrative of “some person randomly decides to put together a ghetto box, whatever.”

20131117_195901

DSC00096

(thanks to my roommate for the shoebox!)

The code is exceedingly simple:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include Wire.h //y'all know what this is really supposed to be
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
 
Adafruit_7segment matrix = Adafruit_7segment();
 
int incomingAudio;
 
void setup(){
  matrix.begin(0x70);
}
 
void loop(){
  incomingAudio = analogRead(A0);
  int adjusted = map(incomingAudio,400,1024, 0,11);
  adjusted = adjusted*-1;
  matrix.print(adjusted, DEC);
  matrix.writeDisplay();
  delay(200);
}

And here’s the Fritzing diagram (though really, Amanda Ghassaei has better circuit diagrams):

Untitled Sketch_bb

 

THIS OR THAT?

Screen Shot 2013-11-18 at 9.45.17 PM

Recently, Microsoft Research presented their first paper on a project they’ve been working on where they are developing electrical components that are also stickers. The idea of sticky circuits is not new–Graffiti Research Lab was creating circuit boards out of mail postage in 2006, but while wearable computing has become immensely popular over the past few years, paper-based computing has not gained similar traction. Fascinated by this weird cousin of wearables, I tried my hand at a postage circuit board, using an ATtiny45 and some conductive tape:

I stuck it in a random elevator near ArtFab and it lasted a couple of hours.  Then, around Halloween, I actually ended up making a joke “ghost meter” that detected the amount of spirits haunting a person and put it in one of the women’s bathroom stalls.

I really liked the idea of “physical apps”–cheap little programs (with varying degrees of usefulness and playfulness) that someone can stick or hang up on a wall for strangers to engage and play with. “Would You Rather” is a game where someone gives a group two (often terrible/gross) situations and the group is forced to vote for one or the other. This game has been turned into multiple apps and internet sites like Kitten War seem to draw inspiration from it. “This Or That” is an electronic poster constructive out of conductive tape, an ATtiny84, and two seven-segment displays that gives passerby a pseudo-anonymous platform to vote on one of two options (which they can also decide on!). While most people were honest in their votes, some people “stuffed the ballot” so to speak–this is probably not going to replace the ballot boxes during the 2016 presidential election, but it’s a fun diversion.

Ultimately, the choice is yours.

Screen Shot 2013-11-18 at 9.44.43 PM

poster_bb

#include <tinywirem .h>
#include <tiny_ledbackpack .h>
 
Tiny_7segment lMatrix = Tiny_7segment();
Tiny_7segment rMatrix = Tiny_7segment();
 
int lCounter = 0;
int rCounter = 0;
const int lButton = 2;
const int rButton = 3;
const int rstButton = 5;
boolean rBoo = false;
boolean lBoo = false;
 
void setup() {  
  lMatrix.begin(0x70);
  rMatrix.begin(0x71);
}
 
void loop() {
  if (digitalRead(lButton) == LOW) {
    lBoo = true;
  } 
  else if ((digitalRead(lButton) == HIGH) && (lBoo == true)) {
    lCounter += 1;
    lBoo = false;
  }
 
  if (digitalRead(rButton) == LOW) {
    rBoo = true;
  } 
  else if ((digitalRead(rButton) == HIGH) && (rBoo == true)) {
    rCounter += 1;
    rBoo = false;
  }
 
  if (digitalRead(rstButton) == LOW) {
    lCounter = 0;
    rCounter = 0;
  }
 
  if (lCounter == 9999) {
    lCounter = 0;
  } else if (rCounter == 9999) {
    rCounter = 0;
  }
  lMatrix.println(lCounter);
  rMatrix.println(rCounter);
  lMatrix.writeDisplay();
  rMatrix.writeDisplay();
  delay(10);
}
</tiny_ledbackpack></tinywirem>

Swetha and Ticha-Bathroom Stall Counter

After hearing Golan’s story about the urinal timer in China, Swetha and I were inspired to do something that also involved bathrooms. Due to the awkwardness that surrounds the bathroom atmosphere and people’s acute concern for public hygiene, we decided to create a measuring device that interplays these two characteristics. Hence, the bathroom stall counter was created: this simple device tallies the number of people who have used a particular bathroom stall and displays the value on the SSD. To do this, we attached a magnet to the bathroom stall door and used a hall effect sensor to determine the magnet’s proximity, which allowed us to tell whether the stall was vacant or occupied.

This project is similar to the work of Adam Frelin ( http://adamfrelin.com/works/TapeFountains-11/ )  in which he dashes into public bathrooms and films himself creating interesting but inconvenient duck tape sculptures that change the function of the bathroom. We were inspired by his erratic but well-edited documentation and his way of interacting with this public space.

IMG_0856

 

Although Swetha did a wonderful job at laser-cutting boxes for our two circuits, our devices still ended up having a ghetto-looking appearance when we secured the parts with masking tape. So, we decided to overplay the ghetto-ness by adorning the boxes with graffiti-esque typography and doodles, which turned out pretty nicely and complemented the bathroom’s atmosphere. Unfortunately, we were not able to mount both of the boxes we made because the sensor would not work for one of them unless it was connected to the laptop.

 

Below are the fritzing diagram and the code:

arduino fritzing

 

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const int hallPin = 2;
const int buttonPin = 9; 
int hallState = 0;        // value read from the pot
 
int buttonState = 0;
int Value = 0;
int prevValue = 0;
 
// Enable one of these two #includes and comment out the other.
// Conditional #include doesn't work due to Arduino IDE shenanigans.
#include  // Enable this line if using Arduino Uno, Mega, etc.
//#include  // Enable this line if using Adafruit Trinket, Gemma, etc.
 
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
 
Adafruit_7segment matrix = Adafruit_7segment();
uint16_t counter = 0;
uint16_t countPeeps = 0;
 
void setup() {
#ifndef __AVR_ATtiny85__ 
#endif
  matrix.begin(0x70);
  pinMode(hallPin, INPUT);
  pinMode(buttonPin, INPUT);
}
 
void loop() {
  hallState = digitalRead(hallPin);      
  buttonState = digitalRead(buttonPin);    
  // map it to the range of the analog out:
  // change the analog out value:
  if(buttonState == LOW){ 
   counter = 0; 
   countPeeps = 0;
 
  }  
 
  if (hallState == HIGH) {        
  	Value =10; 
  } 
  else {
    Value = 0; 
    if(prevValue == 10) { 
    	countPeeps++;
    }
  }
 
  prevValue = Value; 
 
  matrix.println(countPeeps);
  if(countPeeps == 0) {
  	matrix.writeDigitNum(4, 0, false);
  }
  matrix.writeDisplay();
  delay(10);
}
Written by Comments Off on Swetha and Ticha-Bathroom Stall Counter Posted in Assignment-08

Rachel-Measuring Device

The Dis-empathy (Awkwardness) Collar

At its most abstract, this device measures the empathetic distance between two people, or awkwardness. A temperature sensor measures the heat rising off the bearer’s body, which increases as the bearer becomes embarrassed. The number displayed corresponds to the level of embarrassment the bearer feels, which is generated by the cumbersome devices as well as the reactions it elicits. The device, while covering up part of the body that flushes with embarrassment, still displays this emotion in quantified form. However, the cold,inorganic numbers cannot convey the emotion, only express its presence. The person interacting with the bearer has no way of knowing what emotion the bearer is experiencing, in fact the bearer might not be experiencing emotion at all as far they know. I think this turns the bearer into a sort of robot, confined to an uncomfortable slave collar of their own emotion, yet unable to release that emotion.

I arrived at this idea through the 7 segment display. I find it cold, emotionless, and robotically ugly. It is connotationless, un-symbolic, and inorganic. It serves a single functional purpose, to convey some information as numbers, stripping that information of interpretation and meaning. I wanted to make something that expanded this quality to the bearer, turning their human emotions into meaningless numbers.
 photo ACollar1_zps55312ffb.jpg

 photo ACollar2_zps91fe5cf1.jpg

 photo EmotionCollarFritz_bb_zps910187c0.jpg

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*Rachel Moeller, Dis-empathy Collar*/
#include 
 
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
 
Adafruit_7segment matrix = Adafruit_7segment();
 
const int tempPin = 0;
 
void setup() {
#ifndef __AVR_ATtiny85__
  Serial.begin(9600);
  Serial.println("7 Segment Backpack Test");
#endif
  matrix.begin(0x70);
}
 
void loop() {
  float emotionLevel=getVoltage(tempPin);
  float num=1.0;
  float outputNum=emotionLevel*100;
  outputNum=map(outputNum,40,90,0,20);
  int outnum=abs(int(outputNum));
 
  matrix.print(outnum, DEC);
  matrix.writeDisplay();
  delay(2000);
  }
 
  float getVoltage(int pin)
{
 
  return (analogRead(pin) * 0.004882814);
}

 

How Fast Can You Spin?

Spin

My arduino project was installed on the revolving doors of the University Center. Basically, it uses an accelerometer to compute the speed of the doors as someone pushes it. The LED display then reports back the rank of the person out of the total number of people who passed through when the box was installed.

When I heard of the measuring device assignment, I wanted the numbers to be something easy to understand. For some reason, rankings were the first thing that came to mind, since first place is first place no matter what game you play. So I decided to go with a competitive event, and when I learned about the gyroscope, I knew I wanted to do something with rotations. As it turned out though, the revolving doors only needed an accelerometer to measure a force in one direction.

Some problems I ran into, as you will see in the video, is that some people didn’t really understand the colon separating the rank and the total number of participants. Maybe I should have just displayed one number… Another strange issue is that photographs and videos of the LED display could not capture a whole number unless I took a picture really close to the display. I’m not sure if this means the camera goes out of focus, or if the LED display has a slow enough frame rate that the camera picks up each frame. Another issue was that it was a little too bright out for the LED to be put in certain locations. My last problem was that many people ignored the box…

Overall, I had a great amount of fun with this project. I only wish I could leave the project there as a permanent installation to see the rankings accumulate over time.

EDIT:
I tried to get a video of the actual numbers changing, but at night the numbers were too bright. Plus people kept walking through when I tried to get a video. So here is a VERY brief shot of the numbers, if you can see them.

IMG_2940

IMG_2942

All the supplies I used were a FedEx box, masking tape, scissors, and Sugru to attach the thing to glass doors.

Revololving Games_bb

Parts used:
Adafruit ADXL345 – Triple-Axis Accelerometer
Adafruit 0.56″ 4-Digit 7-Segment Display w/I2C Backpack – Red

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//Revolving Games
//Michelle Ma
//Adapted from Adafruit's 7 segment matrix and ADXL345 accelerometer example
//Using a 7 segment matrix and a 3-axis accelerometer, displays the ranking 
//out of a total number of rankings of the velocity of a person using a 
//revolving door.
 
#include <wire .h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
#include <adafruit_sensor .h>
#include <adafruit_adxl345 .h>
 
Adafruit_7segment matrix = Adafruit_7segment();
Adafruit_ADXL345 accel = Adafruit_ADXL345(12345);
 
//If acceleration is greater than this value, start computing ranking!
const int accelThreshold = 2.00;
//There are only two available digits to display total rankings
const int numScores = 99;
 
//array of the speeds (scores)
float velocities[numScores];
int numRankings = 0;
 
void setup() {
  Serial.begin(9600);
  if(!accel.begin())
  {
    /* There was a problem detecting the ADXL345 ... check your connections */
    Serial.println("Ooops, no ADXL345 detected ... Check your wiring!");
    while(1);
  }
  matrix.begin(0x70);
  matrix.setBrightness(5);
  accel.setRange(ADXL345_RANGE_16_G);
  //velocities array initialized with impossible speeds
  for (int i=0; i<numscores ; i++) {
    velocities[i] = 100.0;
  }
}
 
void loop() {
  sensors_event_t event; 
  accel.getEvent(&event);
 
  // X-axis: Left or right, not needed
  // Y-axis: Forward or backward, this will be used
  // Z-axis: Up or down, gravity, not needed
//  Serial.print("X: "); Serial.print(event.acceleration.x);
//  Serial.print("  ");
  Serial.print("Y: "); Serial.print(event.acceleration.y);
  Serial.print("  ");
//  Serial.print("Z: "); Serial.print(event.acceleration.z);
//  Serial.print("  ");
  Serial.println("m/s^2 ");
 
  if (abs(event.acceleration.y) > accelThreshold) {
    float velocity = computeVel(event.acceleration.y);
    velToArray(velocity);
    //Give time for door to stop rotating
    delay(5000);
  }
}
 
float computeVel(float accel) {
  // Will collect over 250 ms
  // Using trapezoid rule to compute estimated velocity
  float sum = 0;
  int samples = 25;
  int dt = 10;
  for (int i=0; i < samples; i++) {
    if ((i==0)||(i==(samples-1))) {
      sum += abs(accel);
    } else {
      sum += 2*abs(accel);
    }
    delay(dt);
  }
  //dt is in milliseconds
  float result = ((dt/1000.0)/2.0)*(sum);
  Serial.print("  Velocity: "); Serial.print(result);
  return result;
}
 
void velToArray(float velocity) {
  int rank;
  //If rankings reach the cap of the matrix, take off the 
  //slowest velocity
  if (numRankings==numScores) {
    velocities[numScores-1] = 100.0;
    numRankings--;
  }
  //first velocity entered
  if (numRankings==0) {
    velocities[0] = velocity;
    rank = 1;
    numRankings++;
  } else {
    //Go through the list from the right
    for (int i=numScores-1; i>0; i--) {
      //place velocity after a faster velocity
      if ((velocity > velocities[i-1])){
        velocities[i] = velocity;
        rank = i+1;
        numRankings++;
        break;
      } else {
        //move velocities down an index
        velocities[i] = velocities[i-1];
        if (i==1) {
          //fastest velocity placed at beginning
          velocities[0] = velocity;
          rank = 1;
          numRankings++;
        }
      }
    }
  }
  Serial.print("  Rank: "); Serial.print(rank);
  Serial.print("  Fastest: "); Serial.print(velocities[0]);
  Serial.print("  NumRankings: "); Serial.print(numRankings);
  displayRank(rank);
}
 
void displayRank(int rank) {
  //Display rank in matrix0 and matrix1
  //Display total rankings in matrix3 and matrix 4
  matrix.writeDigitNum(0, int(rank/10));
  matrix.writeDigitNum(1, rank%10);
  matrix.drawColon(true);
  matrix.writeDigitNum(3, int(numRankings/10));
  matrix.writeDigitNum(4, numRankings%10);
  matrix.writeDisplay();
}
</numscores></adafruit_adxl345></adafruit_sensor></wire>

Are you sitting yourself to death? (Arduino Measuring Device – Julia & Dave)

Project Description

To start this assignment, we brainstormed interesting things to measure, interesting ways to measure them, and possible locations for our measurement device.  We came up with all kinds of ideas—from a person’s repetitive thoughts (through self report) to boredom in class (seeing if we could look at network data and count how many people were on facebook.) In the end, we narrowed our ideas down to these 3:

  1. Measuring light in dark areas where plants grow nonetheless—seeing how much light is actually there.

  2. Measuring the effect of an installation piece on altruism—if we had a countdown that would motivate people to be aware of or donate to distant issues.

  3. (on the quantitative self side of things) measuring how long we spent sitting during the day. This was inspired by a study that indicated that excessive sitting increases health risks and decreases lifespan.

We chose to measure sitting as our final idea because it fit better with the assignment—measuring something that existed already—rather than idea 2, which was very deliberately changing people’s behavior. We also chose to measure sitting because we felt the measurement could be a provocative one, encouraging a wearer to think about their lifestyle choices.

Sensors Used

We used a pressure sensor (a.k.a. round force-sensitive resistor) placed in a back pocket to tell if a person was sitting.

Sketch

Photo Nov 11, 3 37 54 PM

Photos

Video

Code

Github repo: https://github.com/juliat/ems2a8

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include  Wire.h
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
 
// initialize the 7 segment number display
Adafruit_7segment matrix = Adafruit_7segment();
 
// pressure sensor
const int sensorPin = 0;
int pressureReading; // the analog reading from the FSR resistor driver
int sittingThreshold = 900;
 
// cell phone vibrator
int vibratorPin = 7;
 
#define minutesToMillisFactor 60000
 
boolean currentlySitting = false;
float overallTimeSitting = 360*minutesToMillisFactor;
float sitStartTime = 0;
float timeBefore = 0;
 
boolean warningNow;
 
// 0.1 minutes for testing, but this would really be about 30 minutes (for practical use)
const float sitWarningThresholdInMinutes = 0.1;
 
void setup() {
  // get the serial port running for debugging
  Serial.begin(9600);
  Serial.println("Start");
 
  // setup the 7 segment number display
  matrix.begin(0x70);
 
  // initialize vibratorPin
  pinMode(vibratorPin, OUTPUT);
}
 
void loop() {
  pressureReading = analogRead(sensorPin);
 
  checkSitting();
  Serial.println("overallTimeSitting");
  Serial.println(overallTimeSitting);
 
  // how long have I currently been sitting?
  float currentSitDurationInMillis = millis() - sitStartTime;
 
  // warn if I've been sitting too long
  if ((currentSitDurationInMillis &gt; sitWarningThresholdInMinutes * minutesToMillisFactor) 
     &amp;&amp; currentlySitting) {
       warningNow = true;
  }
 
  if (warningNow == true) {
    digitalWrite(vibratorPin, HIGH);
  }
 
  // if I'm sitting, update the display, adding the time delta
 
  matrix.print((long)overallTimeSitting/minutesToMillisFactor, DEC);
  matrix.writeDisplay();
  delay(50);
}
 
void checkSitting() {
  Serial.print("pressure: ");
  Serial.println(pressureReading);
 
  float timeNow = millis();
  // are you sitting?
  if (pressureReading &lt; sittingThreshold) {       // were you sitting last time I checked?       if (currentlySitting == false) {         sitStartTime = millis();         currentlySitting = true;         Serial.println("started sitting");       }       else {         Serial.println("still sitting");         // update overall sitting time         float thisSitDuration = timeNow - timeBefore;         overallTimeSitting += thisSitDuration;                }   }   // are you sitting now   if (pressureReading &gt; sittingThreshold) {
    // did you just get up?
    if (currentlySitting == true) {
      currentlySitting = false; 
      Serial.println("got up");
      warningNow = false;
      digitalWrite(vibratorPin, LOW);
    }
  }
  timeBefore = timeNow;
}

Diagram

Written by Comments Off on Are you sitting yourself to death? (Arduino Measuring Device – Julia & Dave) Posted in Assignment-08