4 min read

Week 3: Not everything needs wires

Week 3 Notes
Background Analog Output: PWM: pulse width modulation creates a pseudo-analog voltage – effective voltage created by constantly changing V; only a few boards can generate a continuous signal duty goes from 0–255, corresponds to 0–5V → even for a 3.3V Arduino Nano? What’s an easy way to choose the...
See notes on labs and textbook readings here.

My assignment this week for Designing Assistive Technology was to create an accessible face mask. I thought I could attach a sensor and provide the wearer useful information to help manage everyday life. For example, an air quality sensor could help an immunocompromised wearer determine the safety of indoor spaces, or an ultrasonic sensor could help a hard-of-seeing wearer detect obstacles or impediments.

I borrowed an ultrasonic sensor from the shop, found a lab on how to use it on a breadboard, and added a speaker that would play if something came within a certain distance. As I built the circuit, however, I began to think about how I could possibly affix all of its components on a face mask that’s essentially held up by some string.

Image of a top-down view of an ultrasonic distance sensor and speaker both connected to an Arduino on a breadboard.
Top-down view of an ultrasonic distance sensor and speaker both connected to an Arduino on a breadboard. 

What if the mask itself had more support? I wondered, and recalled the old headgear in my closet from my high school wrestling days, with three sets of belts so that it stays fastened throughout all the grappling and throwing in a match. I could attach the mask to the front of the headgear, and the circuit components to the ear guards on either side, connected by wires running along the back…

It dawned on me that I was contemplating something I wouldn’t want to wear, and assuming that someone else might just for features that, again, I had assumed they’d need. I recall a paper we read for class called Predictors of Assistive Technology Abandonment by Betsy Phillips and Hongxin Zhao (2000), where the authors found that almost a third of assistive technologies were abandoned, for reasons including that the owners didn’t need them and that their opinions weren’t taken into consideration. Another reading describes design for user empowerment, which includes users, e.g., disabled users, throughout the entire design cycle. I had set off on my idea without any collaboration with my potential users, or research on their needs! When I described this revelation to a classmate, a designer by training, she laughed, and said it was pretty typical to see back in school.

I thought once again about whom I would build for, and at least this week, I think it’s okay that it’s just for me. I split up my original idea from one headache that no one will want to use into two little projects that I like: a mask that doesn’t wrap around the ears, and a theremin, which I share below.


I added a few more lines of code so that ultrasonic sensor values below a certain distance will map onto a range of frequencies, which means that proximity to the sensor will change the pitch of the tone, like a theremin.

const int trigPin = 3;
const int echoPin = 2;
const int speakerPin = 4;
int frequency = 0;
long lastPitchChange = 0;

void setup() {
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  Serial.begin(9600);
}

void loop() {
  // trigger pin low-high-low to send a pulse
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);

  // read pulse
  long duration = pulseIn(echoPin, HIGH);
  int distance = (duration * 0.0343) / 2;
  Serial.print("Distance: ");
  Serial.println(distance);

  // change pitch based on distance from sensor
  if (distance <= 30) {
    frequency = map(distance, 3, 30, 220, 880);
    tone(speakerPin, frequency, 10);
  } else {
    noTone(speakerPin);
  }

  delay(10);
}

When I built my last “instrument”, I used a 220-ohm resistor for the speaker and 3.3V from the Arduino. This time, I’m using a 100-ohm resistor and 5V via USB, which provides much louder sound.

This schematic diagram shows a speaker connected to the 5V V_in input of an Arduino Nano 33 via one terminal, and a 100-ohm resistor through the other. The resistor is connected to the drain of an N-MOFSET transistor, while digital input 4 and ground are connected to the gate and source respectively. A hypersonic distance sensor is also connected to the Arduino. Its VCC and GND pins are connected to V_in and ground, while its echo and trigger pins are connected to digital pins 2 and 3 respectively.
This schematic diagram shows a speaker connected to the 5V V_in input of an Arduino Nano 33 via one terminal, and a 100-ohm resistor through the other. The resistor is connected to the drain of an N-MOFSET transistor, while digital input 4 and ground are connected to the gate and source respectively. A hypersonic distance sensor is also connected to the Arduino. Its VCC and GND pins are connected to V_in and ground, while its echo and trigger pins are connected to digital pins 2 and 3 respectively. 
A breadboard visualization of the schematic above.
A breadboard visualization of the schematic above.

My theremin works almost as intended. Pitch doesn’t shift as smoothly as I’ve heard on actual theremins – I wonder if it may have to do with the delay calls in the script. I’ve also connected the speaker to a transistor, following the example from the Tone Output Lab, but since the entire circuit is being powered through the 5V USB (the Arduino’s V_in is connected to the bus), do I need it?

On the subject of the transistor, if the output from the Arduino is connected to its gate, then how does information about the tone travel to the drain and produce the correct sound?

Video demonstration of pitch frequency as a function of distance from the ultrasonic sensor.