Sunglasses

I made some sunglasses that are super useful for when you need protection from bright lights but also need to be able to look down and take notes with clear vision.

I forgot to take photos for documentation though, so I made this video to make up for it.

 

Here is my code: I got parts of it from the arduino and sparkfun tutorials on accelerometers and servos.

 

#include <Wire.h>
#include <SFE_MMA8452Q.h>
#include <Servo.h>

MMA8452Q accel;
Servo right;
Servo left;

int posSL = 0;
int posSR = 180;

void setup()
{
//myservo.attach(10);
right.attach(9);
left.attach(10);

Serial.begin(9600);
accel.init();
}

void loop()
{
if (accel.available())
{

accel.read();

Serial.println(accel.cx);
if (accel.cx >= 0) {
posSR = 180;
posSL = 0;
} else if (accel.cx < 0) {
posSR = 0;
posSL = 180;
}

right.write(posSR);
left.write(posSL);
}
}

Leave a Reply

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