Introduction: Relaxation Goggles - ITTT

HKU Project - ITTT (If This Then That) - Julia Berkouwer, 1B

Have you ever felt stressed out and you just don't know how to calm
yourself, then you should try these relaxation goggles! You put them on and close your eyes, then a breathing pattern will play. By following this breathing pattern your breathing rythem will go down to breathing in and out 6 times a minute. Doing this it releave dayly stress.

You can also track your breathing intensity by flipping on a switch, using a fsr-sensor.

With this toturial I will guide you through building your own relaxation goggles step by step.

Step 1: Materials and Parts Needed:

Materials:

1x arduino uno;

1xbreadboard or PCV;

3x 10k resistors

Wires(Preferably different colors so it is easier to tell which things are going to the ground and which are going to different pins, etc.);

Some heat shrinking tubes;

2x NeoPixel Ring - 16 x 5050 RGB LED with Integrated Drivers;

1x switch;

1x FSR sensor;

1x SteamPunk goggles (You can buy these at a party shop, they are easy to use because the neopixel ring fits perfectly on the glasses. You always try using other goggles or create your own.);

1x some sort of an (elastick) band to put around your chest.

Tools:
-Laptop

-Soldering iron

-Arduino IDE software

You will see two buttons and a switch on my pvc, I only use the left button to connect it to the switch, I don't use the second button on the right of the picture. I put the buttons on the pvc before realising i don't need them and I needed to use a switch instead.

Below here you'll see pictures of everything I used:

Step 2: Neopixel Rings

The white wire is connected to the ground on the back of the neopixel ring.

The orange wire is connected to the 5V.

And the brown wire is connected to the data input

Step 3: Connections

This is what my breadboard looked like while prototyping, you can use this as a reference.

I also made a layout of the wiring of what it is supposed to look like with just one button.

Step 4: The Code:

It is probably not the most efficient code, but it works for me. Challange yourself and try to make it more efficient ;P


#include 
// Which
pin on the Arduino is connected to the NeoPixels?
#define
PIN            6
// Which
pin on the Arduino is connected to the button
#define
BUTTON_PIN   9 
// How
many NeoPixels are attached to the Arduino?
#define
NUMPIXELS      16
// When
we setup the NeoPixel library, we tell it how many pixels, and which pin to use
to send signals.
// Note
that for older NeoPixel strips you might need to change the third
parameter--see the strandtest
//
example for more information on possible values.
Adafruit_NeoPixel
pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
int pause
= 1; //delay2
int
pause2 = 80; //going down when fsr is being used
int
pause3 = 150; // doing up when fsr is being used
int
delayval = 4; // delay1
int
fsrPin = 0; // the FSR and 10K pulldown are connected to a0
int
fsrReading;
void
setup() {
  pinMode(BUTTON_PIN, INPUT);
  Serial.begin(9600);
  pixels.begin(); // This initializes the
NeoPixel library.
  pixels.show();
}
bool
buttonpressed(int pin){
  return digitalRead(pin);
}
void
loop() { //reads whether pin input is true or false
  fsrReading = analogRead(fsrPin);
  Serial.print("Analog reading = ");
  Serial.print(fsrReading);
 if (buttonpressed(BUTTON_PIN) == true){
//light effect when using fsr sensor
  if (fsrReading > 50){
    pixels.setPixelColor(0, 1,0,1);
    pixels.setPixelColor(15, 1,0,1);
    pixels.setPixelColor(1, 1,0,1);
    pixels.setPixelColor(14, 1,0,1);
    pixels.show();
    delay(pause3);
  }
  if (fsrReading < 52){
    pixels.setPixelColor(0, 0,0,0);
    pixels.setPixelColor(15, 0,0,0);
    pixels.setPixelColor(1, 0,0,0);
    pixels.setPixelColor(14, 0,0,0);
    pixels.show();
 delay(pause2);
  }
  if (fsrReading > 57){
    pixels.setPixelColor(2, 1,0,1);
    pixels.setPixelColor(13, 1,0,1);
    pixels.setPixelColor(3, 1,0,1);
    pixels.setPixelColor(12, 1,0,1);
    pixels.show();
     delay(pause3);
  }
  if (fsrReading < 59){
    pixels.setPixelColor(2, 0,0,0);
    pixels.setPixelColor(13, 0,0,0);
    pixels.setPixelColor(3, 0,0,0);
    pixels.setPixelColor(12, 0,0,0);
    pixels.show();
 delay(pause2);
  }
  if (fsrReading > 65){
    pixels.setPixelColor(4, 1,0,1);
    pixels.setPixelColor(11, 1,0,1);
    pixels.setPixelColor(5, 1,0,1);
    pixels.setPixelColor(10, 1,0,1);
    pixels.show();
  delay(pause3);
  }
  if (fsrReading <67){
    pixels.setPixelColor(4, 0,0,0);
    pixels.setPixelColor(11, 0,0,0);
    pixels.setPixelColor(5, 0,0,0);
    pixels.setPixelColor(10, 0,0,0);
    pixels.show();
     delay(40);
  }
  if (fsrReading > 79){
    pixels.setPixelColor(6, 1,0,1);
    pixels.setPixelColor(9, 1,0,1);
    pixels.setPixelColor(7, 1,0,1);
    pixels.setPixelColor(8, 1,0,1);
    pixels.show();
    delay(pause3);
  }
  if (fsrReading <85){ 
    pixels.setPixelColor(6, 0,0,0);
    pixels.setPixelColor(9, 0,0,0);
    pixels.setPixelColor(7, 0,0,0);
    pixels.setPixelColor(8, 0,0,0);
    pixels.show();
  delay(20);
  }
 }
 else{
    breathe_blue(20, 100, 0,1,1); // normal
effect
  }
}
// Pause
= delay between transitions
// Steps
= number of steps
// R, G,
B = Full-on RGB values
// De void breathe is voor het licht effect als de
fsrsensor niet gebruikt wordt. Deze void wordt in de void loop() weer
aangeroepen.
void breathe_blue(int pause, int steps, byte R, byte G,
byte B) { 
int
tmpR, tmpG, tmpB;         // Temp values
                     // Fade up
                    for (int s=1; s<=steps;
s++) {
                      tmpR = (R * s) /
steps;     // Multiply first to avoid
truncation errors  
                      tmpG = (G * s) / steps;
                      tmpB = (B * s) / steps;
                      for (int i=0;
i
                       
pixels.setPixelColor(0,tmpR,tmpG+1,tmpB);
                        pixels.setPixelColor(15,tmpR,tmpG+1,tmpB);
                      }
                      pixels.show();
                      delay(4);
                    }   
                             // Fade up
                    for (int s=1; s<=steps;
s++) {
                      tmpR = (R * s) /
steps;     // Multiply first to avoid
truncation errors  
                      tmpG = (G * s) / steps;
                      tmpB = (B * s) / steps;
                      for (int i=0;
i
                       
pixels.setPixelColor(1,tmpR,tmpG+1,tmpB);
                       
pixels.setPixelColor(14,tmpR,tmpG+1,tmpB);
                      }
                      pixels.show();
                      delay(4);
                    }   
                    // Fade up
                    for (int s=1; s<=steps;
s++) {
                      tmpR = (R * s) /
steps;     // Multiply first to avoid
truncation errors  
                      tmpG = (G * s) / steps;
                      tmpB = (B * s) / steps;
                      for (int i=0;
i
                       
pixels.setPixelColor(2,tmpR,tmpG+2,tmpB);
                       
pixels.setPixelColor(13,tmpR,tmpG+2,tmpB);
                      }
                      pixels.show();
                      delay(3.5);
                    }   
                    // Fade up
                    for (int s=1; s<=steps;
s++) {
                      tmpR = (R * s) /
steps;     // Multiply first to avoid
truncation errors  
                      tmpG = (G * s) / steps;
                      tmpB = (B * s) / steps;
                      for (int i=0;
i
                       
pixels.setPixelColor(3,tmpR,tmpG+3,tmpB+5);
                       
pixels.setPixelColor(12,tmpR,tmpG+3,tmpB+5);
                      }
                      pixels.show();
                      delay(3);
                    }  
                      for (int i=0;
i
                       
pixels.setPixelColor(0,0,0,0);
                       
pixels.setPixelColor(15,0,0,0);
                      }
                    // Fade up
                    for (int s=1; s<=steps;
s++) {
                      tmpR = (R * s) /
steps;     // Multiply first to avoid
truncation errors  
                      tmpG = (G * s) / steps;
                      tmpB = (B * s) / steps;
                      for (int i=0;
i
                        pixels.setPixelColor(4,tmpR,tmpG+3,tmpB+15);
                       
pixels.setPixelColor(11,tmpR,tmpG+3,tmpB+15);
                      }
                      pixels.show();
                      delay(3);
                    }   
                    // Fade up
                    for (int s=1; s<=steps;
s++) {
                      tmpR = (R * s) /
steps;     // Multiply first to avoid
truncation errors  
                      tmpG = (G * s) / steps;
                      tmpB = (B * s) / steps;
                      for (int i=0;
i
                       
pixels.setPixelColor(5,tmpR,tmpG+4,tmpB+20);
                       
pixels.setPixelColor(10,tmpR,tmpG+4,tmpB+20);
                      }
                      pixels.show();
                      delay(2);
                    }   
                   for (int i=0;
i
                       
pixels.setPixelColor(1,0,0,0);
                        pixels.setPixelColor(14,0,0,0);
                      }
                    // Fade up
                    for (int s=1; s<=steps;
s++) {
                      tmpR = (R * s) /
steps;     // Multiply first to avoid
truncation errors  
                      tmpG = (G * s) / steps;
                      tmpB = (B * s) / steps;
                      for (int i=0;
i
                       
pixels.setPixelColor(6,tmpR,tmpG+2,tmpB+40);
                        pixels.setPixelColor(9,tmpR,tmpG+2,tmpB+40);
                      }
                      pixels.show();
                      delay(delayval);
                    }   
                    for (int i=0;
i
                       
pixels.setPixelColor(2,0,0,0);
                       
pixels.setPixelColor(13,0,0,0);
                      }
                    // Fade up
                    for (int s=1; s<=steps;
s++) {
                      tmpR = (R * s) /
steps;     // Multiply first to avoid
truncation errors  
                      tmpG = (G * s) / steps;
                      tmpB = (B * s) / steps;
                      for (int i=0;
i
                        pixels.setPixelColor(7,tmpR,tmpG,tmpB+44);
                       
pixels.setPixelColor(8,tmpR,tmpG,tmpB+44);
                      }
                      pixels.show();
                      delay(delayval);
                    }   
     // Fade down
  for (int s=steps; s>0; s--) {
    tmpR = (R * s) / steps;     // Multiply first to avoid truncation
errors  
    tmpG = (G * s) / steps;
    tmpB = (B * s) / steps;
    for (int i=0; i
      pixels.setPixelColor(7,tmpR,tmpG,tmpB);
      pixels.setPixelColor(8,tmpR,tmpG,tmpB);
    }
    pixels.show();
    delay(1);
  }  
    // Fade down
  for (int s=steps; s>0; s--) {
    tmpR = (R * s) / steps;     // Multiply first to avoid truncation
errors  
    tmpG = (G * s) / steps;
    tmpB = (B * s) / steps;
    for (int i=0; i
      pixels.setPixelColor(6,tmpR,tmpG,tmpB);
      pixels.setPixelColor(9,tmpR,tmpG,tmpB);
    }
    pixels.show();
    delay(1);
  }  
   // Fade down
  for (int s=steps; s>0; s--) {
    tmpR = (R * s) / steps;     // Multiply first to avoid truncation
errors  
    tmpG = (G * s) / steps;
    tmpB = (B * s) / steps;
    for (int i=0; i
      pixels.setPixelColor(5,tmpR,tmpG,tmpB);
      pixels.setPixelColor(10,tmpR,tmpG,tmpB);
    }
    pixels.show();
    delay(2);
  }  
    // Fade down
  for (int s=steps; s>0; s--) {
    tmpR = (R * s) / steps;     // Multiply first to avoid truncation
errors  
    tmpG = (G * s) / steps;
    tmpB = (B * s) / steps;
    for (int i=0; i
      pixels.setPixelColor(4,tmpR,tmpG,tmpB);
      pixels.setPixelColor(11,tmpR,tmpG,tmpB);
    }
    pixels.show();
    delay(2);
  }  
    // Fade down
  for (int s=steps; s>0; s--) {
    tmpR = (R * s) / steps;     // Multiply first to avoid truncation
errors  
    tmpG = (G * s) / steps;
    tmpB = (B * s) / steps;
    for (int i=0; i
      pixels.setPixelColor(3,tmpR,tmpG,tmpB);
      pixels.setPixelColor(12,tmpR,tmpG,tmpB);
    }
    pixels.show();
    delay(3);
  }  
    // Fade down
  for (int s=steps; s>0; s--) {
    tmpR = (R * s) / steps;     //
Multiply first to avoid truncation errors 
    tmpG = (G * s) / steps;
    tmpB = (B * s) / steps;
    for (int i=0; i
      pixels.setPixelColor(2,tmpR,tmpG,tmpB);
      pixels.setPixelColor(13,tmpR,tmpG,tmpB);
    }
    pixels.show();
    delay(3);
  }  
   // Fade down
  for (int s=steps; s>0; s--) {
    tmpR = (R * s) / steps;     // Multiply first to avoid truncation
errors  
    tmpG = (G * s) / steps;
    tmpB = (B * s) / steps;
    for (int i=0; i
      pixels.setPixelColor(1,tmpR,tmpG,tmpB);
      pixels.setPixelColor(14,tmpR,tmpG,tmpB);
    }
    pixels.show();
    delay(4);
  }  
    // Fade down
  for (int s=steps; s>0; s--) {
    tmpR = (R * s) / steps;     // Multiply first to avoid truncation
errors  
    tmpG = (G * s) / steps;
    tmpB = (B * s) / steps;
    for (int i=0; i
      pixels.setPixelColor(0,tmpR,tmpG,tmpB);
      pixels.setPixelColor(15,tmpR,tmpG,tmpB);
    }
    pixels.show();
    delay(4);
  }  
}

Step 5: Putting Everything Together:

You could just leave all your wires connected to your breadboard or a PVC, that is up to you (I chose to put a PVC on top of the arduino it's nice and neat that way).

The next step is to put heat shrinking tubes around all the wires so it is less of a mess.

If you chose to use a PVC then you should have soldered everything together by now.

After that you put the neopixel rings on the outside of the goggles (make sure the leds are aligned at the buttom) and secure them in place with some tape or glue (I used tape).

You could choose to stick the fsr-sensor to the elastic band with some tape or just leave it out on it's own.

Enjoy your goggles :)