49-713 Designing for the Internet of Things
· 26 members
A hands-on introductory course exploring the Internet of Things and connected product experiences.
The yawn tells you when you need to go to bed and get more sleep.
The Yawn is for personal use in someone’s house to help users know how much sleep they have gotten. This way the user will know if he should go to bed early. The motion of the device is an opening and closing of a four bar linkage. This gesture represents fatigue as it reminds the viewer of a yawn. A black and grey color scheme was used to convey the mood. Users need only to glance at the moving sculpture to see how much sleep they have gotten based on how much the shape opens up. Additionally, a light will change as the user sleeps more going from bright white to signify energy and having enough sleep to purple, signifying the need to sleep more.
We used code and circuit diagrams from:
RGB LED: http://diotlabs.daraghbyrne.me/2-leds-continued/using-rgb-leds/
Servo: http://diotlabs.daraghbyrne.me/6-controlling-outputs/servo/
int servoPin = A5;
Servo myServo;
int servoPos = 0;
int redPin = A4; // RED pin of the LED to PWM pin **A4**
int greenPin = D0; // GREEN pin of the LED to PWM pin **D0**
int bluePin = D1; // BLUE pin of the LED to PWM pin **D1**
int redValue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int greenValue = 255; // Full brightness for an Cathode RGB LED is 0, and off 255
int blueValue = 255;
int pos = 10;
int SleepLost;
void setup() {
// attaches the servo on the A7 pin to the servo object
myServo.attach( A5 );
//Register our Particle to control the servo
Particle.function("servo", servoControl);
// Keep a cloud variable for the current position
//Particle.variable( "servoPos" , &servoPos , INT );
Particle.variable( "SleepLost" , &SleepLost , INT );
pinMode( redPin, OUTPUT);
pinMode( greenPin, OUTPUT);
pinMode( bluePin, OUTPUT);
}
void loop() {
}
int servoControl( String command )
{
// Convert
int hours = command.toInt();
if ( hours > 8)
{
pos = 83;
servoWrite ( pos );
blueValue = 255;
analogWrite(bluePin, blueValue);
}
else if ( hours > 6)
{
pos = 75;
servoWrite ( pos );
blueValue = 204;
analogWrite( bluePin, blueValue);
}
else if( hours > 4 )
{
pos = 60;
servoWrite ( pos );
blueValue = 153;
analogWrite( bluePin, blueValue);
}
else if( hours > 2)
{
pos = 45;
servoWrite ( pos );
blueValue = 102;
analogWrite( bluePin, blueValue);
}
else
{
pos = 20;
servoWrite ( pos );
blueValue = 0;
analogWrite( bluePin, blueValue);
}
return 1;
}
void servoWrite( int a ){
// Convert
int newPos = a;
// Make sure it is in the right range
// And set the position
servoPos = constrain( newPos, 0 , 180);
// Set the servo
myServo.write( servoPos );
// done
}
Click to Expand
YAWN from Mark Byrne on Vimeo.
A hands-on introductory course exploring the Internet of Things and connected product experiences.
The yawn tells you when you need to go to bed and get more sleep.
February 8th, 2017