Introduction: Seasoning Dispenser — an Illusion of Choice Machine

The Sugar n' Spice seasoning dispenser can dispense a variety of spices to make your food or drinks more flavourful! HOWEVER, unless you manage to solve the puzzle it gives you, the machine will almost certainly dispense the wrong spice into you food 😔

Let's take a look at how it's designed, coded, and built.

Supplies

Electrical Components

2x ELEGOO UNO R3 Controller Boards

3x Bread Boards

1x Joystick

1x Servo motor

1x Piezo

3x DC motors

3x Fans

1x Water level sensor

1x Ultrasonic sensor

1x Photoresistor

2x 9V Batteries

3x Transistors

3x Resistors

Many Wires


Materials

2x 18" x 32" Plywood board (3mm thick)

1x Cardboard

3x Spices (black pepper, chili flakes, basil leaves)


Equipment

Computer

Laser Cutter

Exacto knife

Glue

Tape


Software

Arduino IDE

Step 1: Puzzle Logic

Our circuit is a simple chain reaction that follows multiple linear paths. In the above diagram, circular components are sensors, while square components represent actuators.

The puzzle changes every 30 seconds, for a total of four times, thereby the code is divided into 4 conditions that loop on repeat. A “myCounter” variable is introduced in order to keep track of time and change the puzzle at 30 second intervals. 

The joystick, our input sensor device, is divided into 4 quadrants with a non-responsive dead zone in the center to eliminate over-sensitive readings. Each of the quadrants correspond with a different servo motor movement where the rotation angle is set based on the placement of the three sensors. A butterknife-shaped sweeper is attached to the servo motor to extend the servo’s reach and activate the sensors. 

Since there are four quadrants and only three sensors, moving the joystick in one of the four quadrants will NOT dispense seasoning. This “wrong answer” is signaled by the sweeper shaking its head while beeping at the same time. The output that corresponds with each of the four quadrants of the joystick constantly changes, and it is the goal of the player to solve the puzzle and dispense their desired seasoning

Step 2: Arduino Codes


Two separate codes were written for the two arduinos. The first code includes the joystick and servo motor (the butterknife sweeper), while the second code includes the three sensors (water level sensor, photoresistor, and ultrasonic sensor) and the DC motors with fans attached.


Code 1: Joystick + Servo Motor

Begin the code by assigning pin numbers, introducing variables, and including the servo library. Next, set the rotation angles of the servo motor in accordance with the placement of the three sensors; include a fourth rotation angle for the “headshake.”

In the setup section of the code, begin serial connection and set pin modes by assigning the joystick as input and servo motor and piezo buzzer as outputs. Then, calibrate the joystick by obtaining neutral readings via the analog read function.

Moving onto the loop section, start timing the game, and create a while loop for the first 30 seconds. Print out the joystick X and Y coordinates and Quadrant #s. Next, divide the joystick motion into 4 quadrants by writing if/else statements that assign different servo motor rotations for each of the quadrants. Make sure to account for the dead zone when defining the X and Y coordinate bounds in the if/else function. Then, add one count to myCounter to keep track of time and # of trials.

Repeat the same logic for the other three conditions. The only modification is the assignment of the four quadrants with the four rotation angles; by switching up the order of the rotation angles in the if/else statements, the puzzle changes every 30 seconds, and resets itself every 2 minutes.


Code 2: Sensors + DC Motors

First, define the pin numbers and set the speed and duration of the DC motor fans. 

In the setup section, define the sensors as inputs and motors as outputs. Then, obtain neutral readings of the water level sensor and photoresistor via the analog read function.

In the loop section of the code, create an if statement for each of the sensors. 

If the water level senses water, then motor 1 will spin for 1.5 seconds; if the photoresistor is covered and lighting conditions become dimmer, then motor 2 will spin for 1.5 seconds; and finally, if the ultrasonic sensor senses an object (the sweeper) within 10 cm, then motor 3 will spin.

The range of values were adjusted based on the physical machine setup and lighting conditions. The range of responsive values must be large enough to sense a difference in conditions while small enough to omit over-sensitive reactions. For instance, the ultrasonic mistakenly reads a distance of 900+ cm when an object is at close proximity to it. This was accounted for in the code by setting the range of reactive distance between 2 cm and 10 cm.


**Attached below are the Arduino codes to run the system.

Step 3: TinkerCad

Above are fritzing and tinkercad diagrams showing the wire connections between components.

Tinkercad: https://www.tinkercad.com/things/06yVzudR8SH-a2part2songzi-zhou-minh-camilla-hoang-jasmin-kochar-boer-li/editel?returnTo=%2Fdashboard%3Fcollection%3Ddesigns&sharecode=m0ZVNj_2jnxhCF7a8QeHpr00m38f-z5jU1lci4pp4Sw

Step 4: Assembly — Servo Motor & Sweeper

The butter-knife shaped sweeper is attached to a servo motor and is controlled by a joystick. The geometry of the sweeper is design to be have enough surface area so that it could be read by the ultrasonic sensor and photo resistor. We built a base for the joystick that limits the joystick's range of motion, allowing it to only move into one of the four quadrants.

Due to this, moving the joystick into three of the four quadrants will each trigger a sensor. The fourth quadrant does not correspond to any sensor, and moving the joystick into this quadrant will generate a shaking movement accompanied with a buzzing sound. The quadrants that correspond to the sensor change after a certain period of time, creating a puzzle for the user to figure out.

Step 5: Assembly — Three Sensors

Each of the sensor would signal the fan it is connected to turn on if the sensor reads a value within a set range. The main challenge here was to physically calibrate this range and using built parts to refine and assist this process.

Photoresistor - a box is built around the photoresistor to control the sensor's light exposure; the sweeper would move to cover the top of the box, reducing the light source and allowing the photoresistor to read a value within the threshold to turn on the fan.

Water Level Sensor - this sensor is attached to a double teeter-totter system. The first teeter-totter has an elastic band connecting it to the ground; when the sweeper hits this elastic band, it uplifts the second teeter-totter which drops the water level detector into the cup of water. When this happens, the water level detector reaches the threshold of values required to turn on the corresponding fan.

Ultrasonic Sensor - this sensor is set at a permanent position on the machine's base, and when the sweeper moves on top of the sensor, then, the value read by the sensor will fall within the threshold and turn on the fan.

Step 6: Assembly — DC Motors & Fans

We built a container to contain the three fans, which are attached to their respective sensors, and the three types of spices; within this container there are two levels. A porous surface divides the two levels; spices are meant to be dispensed through this porous surface.

At the top level, each of the fans are placed in a distinct compartment; spices are to be put in front of the fan for them to be blown through the porous surface when the fans get turned on. Additionally, a lid must be put on before operating the machine to contain the spices within their designated compartments.

The bottom level is where the food container is to be placed. When the fans turn on, spices will be dispensed onto the food through the porous divider.

Step 7: Video

If the above videos do not play, please use the links below to access the video demonstrations.

Machine Demonstration: https://drive.google.com/file/d/1-peSgMAlO3Q7WXJtyfXbu7nAF5x39JCz/view?usp=sharing

Machine Innerworkings: https://drive.google.com/file/d/1GWKrfM-Ku52WXrAzEXxUmaUaS8eUWnnw/view?usp=drive_link

Step 8: Conclusion


Reflecting on our process, we were faced with a number of challenges, surprises, and successes.


Challenges


Failed Sensor Readings: A major challenge encountered during the assembly process was to establish the range of contact between the sweeper and the ultrasonic sensor and photoresistor; after various assembly and calibration attempts, we successfully determined the positions of the two sensors that would allow them to read signals in the presence of the sweeper. We also adjust the values of sensory thresholds in our code to refine the reading range and ensure that changes in the position of the sweeper are registered.

Double Teeter-Totter System & Water Level Detector: Another challenge we faced is found in the engineering of the double teeter-totter system used to dunk the water level detector into a cup of water. This main problem emerged as we tried to ensure that the sweeper's swinging motion was strong enough to uplift the first teeter-totter, thereby allowing the second teeter-totter to dunk the sensor into the cup of water. We refined this process by connecting an elastic band from the first teeter-totter to the base of the machine: this arrangement would force the uplift when the sweeper swings against the side of the elastic band. We also use a weighted object to make sure the uplift is undone when the sweeper moves away from the elastic band.

Loose wires of DC Motor: The third challenge we encountered was the DC motor's two wires (VCC and GND) becoming loose and disconnecting from the motor body upon prolonged use. In response to this issue, we stripped the wire and reconnected it to the DC motor using superglue as a simple alternative solution to soldering.


Surprises

Blowing Spices: After ensuring that all components of the machine are functioning as desired, we were surprised by the fact that some of the spices were not being dispensed. Upon further inspection, we realized the material used for the fins of the fans were too thin and therefore did not blow on the spice hard enough for them to exit the dispenser. We solved this hilarious issue by layering the fins with an additional layer of tape to increase their thickness.


Successes

This "useless" seasoning dispenser relies on the logic of a chain reaction (shown in the code, circuit, and physical machine), where the player is unaware of the code operating the machine. By adding a rotating algorithm to the code that changes every thirty seconds, players are faced with an illusion of choice, as the machine seems to operate randomly upon first impression. Jiggling around the joystick, however, will eventually reveal the puzzle logic and player must crack the code in order to get the seasoning they'd like.


Opening: March 7th at the 2nd Floor Studio Area

Come meet Sugar n' Spice, the Seasoning Dispenser!

Bring a drink or plate of food and spice it up while testing your puzzle-solving skills!



**This project was created as part of the Physical Computing course (ARC385) at the John H. Daniels Faculty of Architecture, Landscape and Design, HBA in Architectural Studies program at the University of Toronto.

Team Members: Songzi Zhou, Minh (Camilla) Hoang, Jasmin Kochar, Boer Li, Alice Niu.