Stephanie + Maxine Final Project Update

We decided to change our original concept of a wearable piece to a lamp. The idea is that the LED fades based on the wearer’s level of attention. We like the image of someone reading a book or doing work and if their attention wavered their light source would too. Acting as a manifestation of the wearer’s internal state, the light could provide critical feedback to the wearer (the loss of attention and thus progress) and perhaps motivate them to behave differently.

While getting an LED to change brightness based on the output of the mindflex seems relatively simple, it actually was quite challenging to figure out the code to make this successful. We tried a multitude of different strategies (such as changing from using an RGB strip to just a red LED) and employed the help of anyone that could point us in the right direction – Special shout out to Kyle Li and Julie Huynh !!! They both provided us with critical pieces of code that made our project work.

Progress documentation:

photo 1 copy 2

The LED responds to the different levels that the mindflex outputs.

photo 2 copy 2

The brightness changes based on the higher level of attention.

Here is a video of it working : https://www.youtube.com/watch?v=tau6435PHvg&feature=youtu.be

The final code we used :

//this is a mash up of code from the BrainSerialTest that we used in class, code from Kyle Li to break up the CSV, and code from Julie Huynh to assign the serial output to a PWN and thus connect it to the LED

#include <Brain.h>
int lightPin = 0;  //define a pin for Photo resistor
const int ledPin = 6; // the pin that the LED is attached to
int incomingByte;      // a variable to read incoming serial data into
int brightness = 0;    // how bright the LED is
int fadeAmount = 10;    // how many points to fade the LED by
Brain brain(Serial);
void setup()
{
    Serial.begin(9600);  //Begin serial communcation
    pinMode(ledPin, OUTPUT);
    analogWrite(ledPin, 255);
}
void loop()
{
     if (brain.update()) {
        //Serial.println(brain.readErrors());
        String temps = brain.readCSV();
        String arrays[3];
        //String[] arrayS = temps.split(“,”);
        //Serial.print(brain.readCSV());
        int index1 = -1;
        int index2;
        for(int i=0; i<3;i++){
        index1 = temps.indexOf(“,”,index1+1);
        index2 = temps.indexOf(“,”,index1+1);
        arrays[i] = temps.substring(index1+1, index2);
        }
        Serial.print(“data:”);
        Serial.println(arrays[2]);
        //String [] subtext = splitTokens(temps,”,”);
    }
    //Serial.println(analogRead(lightPin));
   delay(10); //short delay for faster response to light.
   // see if there’s incoming serial data:
  if (Serial.available() >= 0) {
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
//    Serial.print(“sensor = “);
//    Serial.print(sensorValue);
//    Serial.print(“/t output = “);
//    Serial.print(outputValue);
    analogWrite(ledPin, incomingByte);
    delay(20);
  }
}

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>