Hearts and Hands: Connected Spaces

Combining Studio Classrooms with Distance Learning

Made by kaylageer and Hayley

Studio-based classrooms provide opportunities for collaboration and hands-on learning, while distance education classes feel...distant. How do we mesh the benefits of studio classrooms with the growing trend of distance education? A few of the many problems include: - Knowing which students are present, and how to leverage different skills and learning styles from or across a distance. - Easily knowing who has a question or wants to speak since visibility is more limited. - Knowing whether or not students are interested without direct eye contact.

Created: March 4th, 2015

0
//Arduino 1.0+ Compatible only

// Code to retrieve heartrate information from the Polar Heart Rate Monitor Interface via I2C
// Part: http://www.sparkfun.com/products/8661
// Article:  http://bildr.org/2011/08/heartrate-arduino/

#include <Wire.h>

#define HRMI_I2C_ADDR      127
#define HRMI_HR_ALG        1   // 1= average sample, 0 = raw sample

void setup(){
  setupHeartMonitor(HRMI_HR_ALG);
  Serial.begin(9600);
  
  Wire.begin();
}

void loop()
{
  int heartRate = getHeartRate();
//  Serial.println(heartRate);
  byte heartRateByte=(byte)heartRate;
  Serial.println(heartRateByte);
  Wire.beginTransmission(5);
  Wire.write(heartRateByte);
  Wire.endTransmission();
 /*
  while(Serial.available())
  {
    int r = Serial.read();
    if(r > 0)
    {
      Wire.beginTransmission(5);
      Wire.write(r);
      Wire.endTransmission();
    }
    else if(r == 0)
    {
      Wire.beginTransmission(5);
      Wire.write(0);
      Wire.endTransmission();
    }
  }
 */
  delay(1000); //just here to slow down the checking to once a second
}

void setupHeartMonitor(int type){
  //setup the heartrate monitor
  Wire.begin();
  writeRegister(HRMI_I2C_ADDR, 0x53, type); // Configure the HRMI with the requested algorithm mode
}

int getHeartRate(){
  //get and return heart rate
  //returns 0 if we couldnt get the heart rate
  byte i2cRspArray[3]; // I2C response array
  i2cRspArray[2] = 0;

  writeRegister(HRMI_I2C_ADDR,  0x47, 0x1); // Request a set of heart rate values 

  if (hrmiGetData(127, 3, i2cRspArray)) {
    return i2cRspArray[2];
  }
  else{
    return 0;
  }
}

void writeRegister(int deviceAddress, byte address, byte val) {
  //I2C command to send data to a specific address on the device
  Wire.beginTransmission(deviceAddress); // start transmission to device 
  Wire.write(address);       // send register address
  Wire.write(val);         // send value to write
  Wire.endTransmission();     // end transmission
}

boolean hrmiGetData(byte addr, byte numBytes, byte* dataArray){
  //Get data from heart rate monitor and fill dataArray byte with response
  //Returns true if it was able to get it, false if not
  Wire.requestFrom(addr, numBytes);
  if (Wire.available()) {

    for (int i=0; i<numBytes; i++){
      dataArray[i] = Wire.read();
    }

    return true;
  }
  else{
    return false;
  }
}
Click to Expand
0
#include <Wire.h>

//code for lights to respond to heart rate
//#define wwLED_PIN 6
//#define pLED_PIN 9
#define bgLED_PIN 11

byte heartRateByte=0;
int x = 0;

void setup() {
  Wire.begin(5);    // Start I2C Bus as a Slave (Device 5)
  Wire.onReceive(receiveEvent); // register event
  Serial.begin(9600); //start serial for output
  
//  pinMode(wwLED_PIN, OUTPUT);
//  pinMode(pLED_PIN, OUTPUT);
  pinMode(bgLED_PIN, OUTPUT);
  
//  digitalWrite(wwLED_PIN, LOW);
//  digitalWrite(pLED_PIN, LOW);
  digitalWrite(bgLED_PIN, HIGH);
}

/*void dim(){
  //set BG LED to half brightness
  for (int brightness=0;brightness<130;brightness++){
    analogWrite(bgLED_PIN,brightness);
    delay(10);
  }
  pinMode(pLED_PIN, LOW);
  pinMode(wwLED_PIN, LOW);
}*/

/*void pulse(){
  pinMode(bgLED_PIN, LOW);
  //set ww pulse, p pulse
  for (int brightness=0;brightness<256;brightness++){
    analogWrite(pLED_PIN,brightness);
    analogWrite(wwLED_PIN,brightness);
    delay(10);
  }
  delay(250);
  for (int brightness=255;brightness>=0;brightness--){
    analogWrite(pLED_PIN,brightness);
    analogWrite(wwLED_PIN,brightness);
    delay(10);
  }
}*/

/*void Blink(){
  //blink bg
  digitalWrite(bgLED_PIN, HIGH);
  //blink p
  digitalWrite(pLED_PIN, HIGH);
  //blink ww
  digitalWrite(wwLED_PIN, HIGH);
  delay(500);
    //blink bg
  digitalWrite(bgLED_PIN, LOW);
  //blink p
  digitalWrite(pLED_PIN, LOW);
  //blink ww
  digitalWrite(wwLED_PIN, LOW);
  delay(500);
}
*/
/*void off(){
  pinMode(bgLED_PIN, LOW);
  pinMode(pLED_PIN, LOW);
  pinMode(wwLED_PIN, LOW);
}*/

void receiveEvent(int howMany)
{
 while(Wire.available())
  {
    byte r = Wire.read();
    x=r;
    if(r > 0)
    {
    int heartRate = (int) r;
    Serial.println(heartRate);
    }
    else if(r == 0)
    {
      Serial.print("error");
    }
    else
    {
      Serial.print("error2");
    }
  }
}

void loop()
{
  delay(100);
  if (x>0 && x<=80)
  {
    digitalWrite(bgLED_PIN, HIGH);
  }
  else if (x>80 && x<=100)
  {
    digitalWrite(bgLED_PIN, LOW);
  //  pinMode(pLED_PIN, HIGH);
  }
/*  else if (x>100 && x<=184)
  {
    Blink();
  }
  else if (x>184)
  {
    off();
  }
  else if (x == 0)
  {
    off();
  }*/
}
Click to Expand
x
Share this Project


About

Studio-based classrooms provide opportunities for collaboration and hands-on learning, while distance education classes feel...distant. How do we mesh the benefits of studio classrooms with the growing trend of distance education? A few of the many problems include:

- Knowing which students are present, and how to leverage different skills and learning styles from or across a distance.
- Easily knowing who has a question or wants to speak since visibility is more limited.
- Knowing whether or not students are interested without direct eye contact.