Punkbot
Made by Qin Bian
Made by Qin Bian
Want to be reminded to take a break? Want to stretch with your friends on a click? Punkbot is here to help!
Created: February 5th, 2018
My friend, Henri, tends to sit in front of his computer for long hours at work. Even though he knows the importance of taking regular breaks to stretch and distress, he often forgets to do so without proper reminders. On the occasions when he wants to take a break, he'd love to mingle with his colleagues. However, the current flow of having the intention, opening up the slack channel, thinking about what to say, typing up the message, then clicking on the "send" button sometimes have deterred him from actually taking a break with others. How can we nudge Henri to take and enjoy the breaks?
To get started, I first researched the existing IoT projects online. I learned that ultrasonic sensor can detect the object's distance. Thinking that the distance could effectively reflect people's position and activities, I decided to use the ultrasonic sensor to detect if people have been sitting for too long.
Next, I followed the tutorials provided by the Sparkfun website (http://www.instructables.com/id/Simple-Arduino-and-HC-SR04-Example/) and started building a basic circuit using the ultrasonic sensors and two LEDs which are used to indicate the status. To ensure that the device sends a break reminder email to the person if he/she sits still for 15 minutes, I added a Timer object in my code, which tracks how long the system has been in one state. I then connected the particle photon to the online Particle Console and used the IFTTT to send reminder emails when the break time event is triggered.
For the second part of this project, I added a tactile switch to the circuit so that when people click on the switch, a slack message will be automatically sent to the selected channel asking others if they want to take a break together. I again used the IFTTT to achieve this goal.
Lastly, the look of ultrasonic sensor always reminds me of a robot. Thus, I 3D-printed a case and made it a bit more adorable so that it may give people a sense of companionship when they are at work.
int trigPin = D2;
int echoPin = D3;
int led = D4;
int led2 = D5;
int sittingTime = 0;
int sit = false;
int count = 0;
int buttonPin = D6;
int buttonState = 0;
int previousState = 0;
Timer timer(1000, print_every_second);
void print_every_second()
{
if (sit == true && count > 900){
Serial.println(count++);
Particle.publish("SittingTooLong", "YES");
count = 0;
} else if (sit == true){
Serial.println(count++);
} else {
count = 0;
}
}
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(led, OUTPUT);
digitalWrite(led,LOW);
pinMode(led2, OUTPUT);
digitalWrite(led,LOW);
pinMode(buttonPin, INPUT);
timer.start();
}
void loop() {
long duration, distance;
digitalWrite(trigPin, LOW); // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trigPin, HIGH);
// delayMicroseconds(1000); - Removed this line
delayMicroseconds(10); // Added this line
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance < 10) { // This is where the LED On/Off happens
digitalWrite(led,HIGH); // When the Red condition is met, the Green LED should turn off
sit = true;
digitalWrite(led2,LOW);
} else {
sit = false;
digitalWrite(led,LOW);
digitalWrite(led2,HIGH);
}
/* if (distance >= 200 || distance <= 0){
Serial.println("Out of range");
}
else {
Serial.print(distance);
Serial.println(" cm");
}*/
//Switch control
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH && previousState == LOW){
//do something
Particle.publish("buttonPress", "HIGH");
}
previousState = buttonState;
Serial.println(buttonState);
delay(500);
}
Click to Expand
Through this project, I learned to dissect a complicated IoT device into smaller parts and conquer each part separately. This process made the originally intimating project much easier. Additionally, I also got opportunities to explore different electronics online communities, which will be really helpful to me in the long run.
A hands-on introductory course exploring the Internet of Things and connected product experiences.
Want to be reminded to take a break? Want to stretch with your friends on a click? Punkbot is here to help!