A pillow that doubles as a nightlight. If the user hugs the pillow, the pillow will illuminate and frighten all the potential monsters away. Once the user falls asleep (ideally not on top of the pillow), the pillow will shut off and save batt
ery. We chose red because red lights are shown to help people fall asleep (verses blue), and we thought a heart would be endearing.
Step one: Starting Simple
In our project, the pressure sensor acts as a type of switch. For the first prototype, we used an LED and simply tried to make it blink.
Step two: Fading Under Pressure
It was time take it up a step and to integrate the pressure sensor and LED strip. First, we began with the pressure sensor and fading an LED. In order to fade, we had to turn the analog input (the pressure detected by the pressure sensor) into the digital output (the brightness of the LED). We also became aware of the fact that fading an LED is just an illusion, and that fading of an LED is actually faked with pulse width modulation, which creates an analog-like output with digital values.
Then came the LED strip. We first decided on an LED strip instead of a few LEDs because we wanted our pillow to to glow like a nightlight, instead of just light up in a few designated locations. We soon were awakened to how difficult using LED strips can be. The first thing we learned, was that LED strips need great amounts of power. As much as we wanted our pillow to not strangle our users in the night, this prototype pillow would have to be plugged in in order to light. However, we still needed the 5V from the Arduino, so in addition to plugging our pillow in to power up the LED strip, we also needed a power source for the Arduino itself. In the future, we would prefer to add a battery to the Arduino to power the 5V, instead of having to plug the Arduino into the computer to get that power. We also discovered how to use a transistor, where one leg is the base, one is the collector, and one is the emitter. We connected the collector to the negative end of the LED strip, which in this case is the R strip that we wanted to light. This was because we discovered that the LED RGB strips shared a common ground, not a common power. Apparently every LED strip is slightly different, so discovering this was vital to our project. The transistor worked at the intermediary between the pressure sensor and the LED, making sure that the fading worked. In addition, soldering to an LED strip is a struggle in itself, because of how flexible the strip can be and what little space you have to solder onto. This became the source of quite a few soldering problems early on.
Let’s Take a Trip Down Code Road:
In the code, we first initialize what pins we are using. The buttonPin is 0, and the ledPin is 9. We set the buttonState and mapped_value to 0 as global variables so that we can change it later on. In the setup, we designate which pins will be output (led brightness), and input (pressure). We also start the serial monitor.
In the loop, we set the buttonState to read the state of the buttonPin. This code was originally borrowed from the fade example from Arduino, where the variables were previously named. If we were moving forward, we would definitely rename the variables so that they were a little clearer. Normally, pressureValue is binary (especially in cases with a switch). In our case, it’s analog, since the value pressureValue that comes from the pressure sensor is not 0’s and 1’s, but instead a value between 0 and 1023. First we read from the sensorPin the pressure detected by the pressure sensor, and set it to pressureValue. We then map the values collected from the analogRead. Since the range for the pressure sensor is between 0 and 1023, and the range for the LED is between 0 to 255, we reset the values collected from the pressure sensor to values that fit in the range of the LED brightness. Then, send our mapped value, or the value that can be read by the LED to the ledPin, so that the LED reflects the value collected from the pressure sensor.
Ben did an absolutely fantastic job at designing and sewing the heart. We used a t-shirt from the material room to ensure that we were reusing fabric and not being wasteful. We also found an extra pillow, from which we reused the stuffing for our project. The letters were laser-cut from felt, and helped to offer a bit of guidance on what the intended interaction with the pillow was.
Initially, we planned to solder everything onto a perforated board. However, once we learned that it was unnecessary to undertake such a feat, we left our project within the breadboard. We soldered additional wires to the pressure sensor (since we aren’t allowed to put the pressure sensor into the board).
Most of our major problems stemmed from the LED strip. Due to its needy power-hungry nature, plugging the pillow was a hassle. Then, fading the lights with the transistor was something that wasn’t too easy to figure out. Finally, our main problem became that the LED strip did not want to bend. Although it bent at first, after a few more tries of having the LED strip inside the pillow, we discovered that parts of the LED strip would not light if the strip was bent in a particular manner. Our LED strip malfunctioning became the default for our strip, and we started realizing that perhaps several LEDs would have been a better decision.
Video of the LED strip being fussy and not cooperating.
LED strips are great, but also very difficult to use. They require large amounts of power, and are not easy to solder to. Since strips can vary, the RGB connectors can either share common ground, or common power. Moreover, they do not light if twisted in very slight angles. Overall, LED strips are not meant for soft circuits, and I would not recommend them to anyone else in the future in this class.