ITP Blog

Group Project — Social Distancing Crown

Physical Computing — October 07, 2020

Approaching the Problem with Humor

Daniel, Yonatan and I brainstormed and decided that we would like to create something dorky and useful at the same time. This is how we came to the idea of making a wearable device, particularly something that looks like a hat, that would detect whether someone is too close to you from behind.

The hat would feature a sensor placed in the back of the hat that would trigger LEDs to flash, a finger to wave, and a speaker to create pitches at the intruder. The pitches will be in an ascending pattern in an attempt to mimic someone saying "no, no, no" while wagging a finger. We thought this would be a cute and humorous piece during this stressful time.

Inspiration

We got inspired by Simone Giertz's works, also known as "shitty robots".

What We Used

For the first prototype we decided to use Arduino, NeoPixels LED that we found on the ITP floor, speaker, ultrasonic ranger, as well as a servomotor that would hold a card box hand. Below is a rough sketch, drawn by me during the brainstorming process.

Prototype Sketch

Not the best drawn sketch but it did its job!

Part One — Individual Work

As the device needed multiple parts to work together, we decided to divide the work between us to understand how each part works independently first. Daniel worked on the NeoPixels, Yonatan worked on the servomotor so that it could properly wag the finger and my job included the ultrasonic ranger and making the speaker say "No, no no!". We used Discord for communication. Please check out Daniel's and Yonatan's blog posts to see their process.

Working with Ultrasonic Ranger

I had the chance to work with the ultrasonic ranger from the previous labs but this time I faced some different issues.

Because the objects that approached the ranger weren't plain, it would sometimes output a very big number in the middle of the small numbers while getting the results from the pulseIn() function. This is why I had to add more code to the code from the previous labs where it would check whether the two values in a row were small to make sure there was an object close to the sensor.

int distance;
long duration;
int previousValue = 0; // this value exists to check if two values in the row equal to distance < 10 then do something

void setup() {
  pinMode(2, OUTPUT);
  Serial.begin(9600);
  Serial.println("started");
}
void loop() {
  digitalWrite(2, LOW);
  delayMicroseconds(2);
  digitalWrite(2, HIGH);
  delayMicroseconds(10);
  digitalWrite(2, LOW);
  duration = pulseIn(4, HIGH);
  distance = duration * 0.034 / 2;
  Serial.println(distance);
  if(distance <= 10 && previousValue <= 10) {
    // do something
  }
  delay(500);
  previousValue = distance;
}

In the code above I added the additional variable called previousValue that is equal to the previous value the the sensor was outputting.

Working with the Speaker and External Libraries

As for the speaker it was more challenging as I had to figure out how to make it say the human words with pitches only. I found a library called Talkie that had numerous english words that the speaker could play. It was also said that the library worked with all current Arduino models except Mega and Leonardo so I decided to give it a try with my Nano.

I downloaded it and tried to launch one of the examples and oops! It did not work! It could not even upload the code to the Arduino, outputting multiple error messages about the wrong Int type. ( Unfortunately, forgot to make a screenshot ;( ) After hours of debugging and unplugging, I decided to try the code with the Uno to see whether I was doing something wrong. With Uno, it uploaded the code fine and I could hear the speaker saying the real words!

The Speaker and Uno

Because the Arduino Nano 33 IoT is relatively new, seems like there are still many exceptions you should consider while using libraries, speakers or certain sensors. Turned out, Daniel's NeoPixels did not work well with Nano too so all three of us decided to use Arduino Uno for this project.

#include <Arduino.h>

#include "Talkie.h"
#include "Vocab_US_Large.h"
#include "Vocab_US_TI99.h"
#include "Vocab_Toms_Diner.h"

Talkie voice;
int distance;
long duration;
int previousValue = 0; // this value exists to check if twovalues in the row equal to distance < 10 then do something

void setup() {
  pinMode(2, OUTPUT);
  pinMode(3, INPUT);
  Serial.begin(9600);
  Serial.println("started");
}
void loop() {
  digitalWrite(2, LOW);
  delayMicroseconds(2);
  digitalWrite(2, HIGH);
  delayMicroseconds(10);
  digitalWrite(2, LOW);
  duration = pulseIn(4, HIGH);
  distance = duration * 0.034 / 2;
  Serial.println(distance);
  if(distance <= 10 && previousValue <= 10) {
    voice.say(spt_NO);
    voice.say(spt_NO);
    voice.say(spt_NO);
  }
  delay(500);
  previousValue = distance;
}

Part Two — Speaker, Ultrasonic Ranger and the NeoPixels

After the individual parts were ready it was time to merge the code. First, we tried to make the NeoPixels and Speaker work together along with the ultrasonic ranger.

This is when we encountered the first issue while merging the code. The Arduino code in C that we wrote mostly worked synchronously which means it was important to know where to put which function first. Daniel wrote a separate function to activate the NeoPixels LEDs and we decided to put it at the end of the if/else statement first. This resulted into hearing the "No, no, no" first and seeing the red LEDs only after that which was a too slow reaction.

It is also important to note how quiet the speaker was. Even though it clearly was saying "No, no, no", but to hear that you had to put it close to your ear. We do need a sound amplifier to make it louder but we decided that for the Social Distancing Crown version 1.0 it should not be a problem.

Another problem we encountered was the battery. We connected the 9V battery to the NeoPixel first and it did not work until we connected all the parts to the Arduino itself. Next we had to figure out how to power it all while still making it work with the Arduino. Later in this blog you will see that we get the same problem with the batteries when trying to connect the servomotor.

Please check out Daniel's post to see the code for the NeoPixels merged with an ultrasonic ranger and a speaker.

Part Three — Building the Housing for the Components

For the prototype 1.0, Daniel and I decided to use whatever we find on the floor. Next Daniel cut the holes to place the speaker and ultrasonic ranger. Daniel and I also spent some time to solder the wires for the NeoPixels and speaker to make the whole product look cleaner and also to make sure everything is going to work when you put the crown on your head.

Building the House 1 Building the House 2

Although, for the version 2.0 it would be nice to use a smaller speaker, the result looked quiet like a crown (lol).

Building the House 3

Daniel also had an artificial head to put it on to make sure the crown would fit on the one's head.

Part Four — Connecting the Servomotor

Finally, we connected the servomotor by fixating it on the top of the crown. We also used a card box to cut out a hand that would wag whenever you come close to the crown.

Social Distancing Crown 1 Social Distancing Crown 2

Please check out Yonatan's blog to see his process of making the servomotor work.

As I said earlier, while connecting the servomotor we got the same problem with the battery. The problem was not fixed even today. Our servomotor would work only once and then if you continue approaching the ultrasonic ranger only the speaker and NeoPixels would react. We also checked whether the servomotor received any data and seems like it did. Sometimes it would work twice but very slowly, so we reckon it might be because of the synchronous code that doesn't allow the servomotor to complete its cycle.

Final Result

And here it is, the social distancing crown version 1.0!

~

What Can We Do Next?

There are multiple things that could be improved besides the look itself:

  1. For this version we used mostly basic components. For example, it would be great to use a smaller speaker as well as the sound amplifier to make it louder.
  2. Use a different distance sensor. By now, the ultrasonic ranger detects a very small distance which is why in real life the social distancing crown cannot help much with the actual social distancing.
  3. Replace the wires and the breadboard with the copper tapes for the overall aesthetics.

We also got a lot of feedback on the project. We were also advised to actually try to wear the crown on the streets and see the reactions of people around. Trying it out with the version 2.0 would be actually so much fun!

Thanks, thanks, thanks

I would like to thank Daniel and Yonatan for working with me on this amazing project. Also, cheers to David Rios for answering all our questions and helping with our struggles.


© built during the year of masks and social distancing by yonaymoris with Gatsby