Categories
Uncategorized

Gloria‘s midterm project display

PROJECT TITLE – YOUR NAME – YOUR INSTRUCTOR’S NAME

Project title: Squeeze Competition

Group members: Gloria Liang, Maggie Wang

Instructor: Gottfried Haider

CONTEXT AND SIGNIFICANCE 

According to my understanding of interactivity, it would be better to have both human-human and human-device interaction in the project. Just like a balancing robot I read about online, not only can he check his surroundings to keep the balance, but he can also help his owners transport things which is of practical value. So we want to design a game that can have multiplayer interaction. In order to make the game more interactive, we decide to set up speed competition between players. But we think our work should not only be entertaining but preferably also have some practical value. For example, it can be used in real life or bring people some inspiration.

At the same time, while browsing through the list of devices, we found water sensors. Water is a resource that human beings depend on. There are many places in life that involve water. Therefore, there is a high probability that water-related interactions can also be useful outside the game. What’s more, using water to make people interact with each other was cool, so we had the idea of using it. Although there is a risk of making the scene messy💦, we decided to take on the challenge. Since there is no water sensor in the school, we used a moisture sensor instead in the project.

CONCEPTION AND DESIGN

We designed a two-person race. A man took the fireman’s side. His job was to squeeze water into the box. Another man played the role of arsonist, whose task was to squeeze water from a box into a bottle.

The process of the game is : first fastLED lights up four times, and each time the number of lights increases by two. For the last time, all lights turn green and the race begins. Two players squeeze the same water bottle to keep the game fair. We take advantage of atmospheric pressure differences to control water intake/discharge. (The arsonist’s pipe is deep in the box, short in the bottle. The fireman’s pipe is short in the box but long in the bottle, deep to the bottom) After 20 seconds, a buzzer will sound for 3 seconds to indicate that the game is over, and fastLED will light up the winning side’s color (arsonist: red, Fireman: Blue)

Given the materials, most of what we use is plastic because plastic is waterproof. (plastic boxes, bottles of mineral water, and plastic pipes).In addition, we used cardboard decorations and instructions so that players could quickly understand the rules of the game. In terms of sensors, we borrowed fastLED and humidity sensors and the other materials are from Arduino boxes. 

FABRICATION AND PRODUCTION

I mainly drew pictures, punched holes for the lid and found materials. Maggie wrote the instructions for the game. We did the programming and everything else together.

Maggie and I discussed the design drawing together first, and then we tried different methods to achieve the desired effect.

First of all, we’ve been trying to figure out how do you move water around without messing it up. We once wanted to try using pumps to move water but found that our water was too shallow and couldn’t be sealed, so we ended up switching to a mineral water bottle instead.

These are the pumps that were first tried.

And then we started building. I used a drill to drill three holes in the lid of the plastic box, two for the water guide and one for the sensor. 

Then we add the right amount of water to both bottles and boxes. After making sure the system was working properly, we started working on programming.

We used the millis () function and moisture sensor function learned from the Internet.  But we were very confused about how to code fastLED, so our code for fastLED started out simple: keep alternating red and blue for the first 20 seconds, then show the winner’s color at the end. But after learning that fastLED can do more than we knew, we started trying to make it more lively and complex.

I asked my professor for help and programmed each LED. In this way, when the moisture sensor feels different values, the state of the whole lamp belt will be different. (The more water the arsonist absorbs, the more red lights there are. The more the fireman squeezes, the more blue lights there are)

You can see how it works by simply moving the sensor up and down.

After learning how to code each LED, I decided to optimize the unit a little more. So we improved the pre-game code so that players could see exactly when the game was going to start. The final effect is like this.👇

In order to make the work more interesting, we took advice from the professors and drew different figures on the two sides.👻

Finally, we taped the two catheters to the box to make them more stable. And then the whole thing looks like this.

In the user test, the bottles were crushed by players coming in and we realized that was what we needed to work on. But we tried different tools and couldn’t find a suitable replacement. In the end, the effect can only be achieved by constantly changing the bottle. We also realized that the instructions to both sides were not clear enough. So I added two figures on top of the box and brought the light strip to the front so the player could see it. But because the lights were too bright, I covered them with black transparent paper.

The code:

#include <FastLED.h>

#define NUM_LEDS 8

#define DATA_PIN 3
#define CLOCK_PIN 13
const int sensor_pin = A1; /* Soil moisture sensor O/P pin */
float smoothed_moisture;

float final_score = 0;

CRGB leds[NUM_LEDS];

void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
Serial.begin(9600);

}

void loop() {
float moisture_percentage;
int sensor_analog;
sensor_analog = analogRead(sensor_pin);
moisture_percentage = (((sensor_analog / 1023.00) * 100));

if (millis() < 20000) {
if (millis() < 1000) {
leds[0] = CRGB::Red;
leds[1] = CRGB::Red;
leds[2] = CRGB::Black;
leds[3] = CRGB::Black;
leds[4] = CRGB::Black;
leds[5] = CRGB::Black;
leds[6] = CRGB::Black;
leds[7] = CRGB::Black;
}
if (millis() < 2000&& millis() > 1000) {
leds[0] = CRGB::Red;
leds[1] = CRGB::Red;
leds[2] = CRGB::Red;
leds[3] = CRGB::Red;
leds[4] = CRGB::Black;
leds[5] = CRGB::Black;
leds[6] = CRGB::Black;
leds[7] = CRGB::Black;
}
if (millis() < 3000&& millis() > 2000) {
leds[0] = CRGB::Red;
leds[1] = CRGB::Red;
leds[2] = CRGB::Red;
leds[3] = CRGB::Red;
leds[4] = CRGB::Red;
leds[5] = CRGB::Red;
leds[6] = CRGB::Black;
leds[7] = CRGB::Black;
}
if (millis() < 4000&& millis() > 3000){
leds[0] = CRGB::Green;
leds[1] = CRGB::Green;
leds[2] = CRGB::Green;
leds[3] = CRGB::Green;
leds[4] = CRGB::Green;
leds[5] = CRGB::Green;
leds[6] = CRGB::Green;
leds[7] = CRGB::Green;
}

if (millis() < 4000&& millis() > 3000) {
tone(8, 262);
} else {
noTone(8);
}

smoothed_moisture = smoothed_moisture * 0.99 + moisture_percentage * 0.01;

// map 40-60% to the number of blue pixels
if (millis() < 20000&& millis() > 4000) {
if (smoothed_moisture > 42.5) {
leds[0] = CRGB::Blue;
} else {
leds[0] = CRGB::Red;
}
if (smoothed_moisture > 45) {
leds[1] = CRGB::Blue;
} else {
leds[1] = CRGB::Red;
}
if (smoothed_moisture > 47.5) {
leds[2] = CRGB::Blue;
} else {
leds[2] = CRGB::Red;
}
if (smoothed_moisture > 50) {
leds[3] = CRGB::Blue;
} else {
leds[3] = CRGB::Red;
}
if (smoothed_moisture > 52.5) {
leds[4] = CRGB::Blue;
} else {
leds[4] = CRGB::Red;
}
if (smoothed_moisture > 55) {
leds[5] = CRGB::Blue;
} else {
leds[5] = CRGB::Red;
}
if (smoothed_moisture > 57.5) {
leds[6] = CRGB::Blue;
} else {
leds[6] = CRGB::Red;
}
if (smoothed_moisture > 60) {
leds[7] = CRGB::Blue;
} else {
leds[7] = CRGB::Red;
}
}

FastLED.show();

/*
leds[0] = CRGB::Red;
leds[1] = CRGB::Red;
leds[2] = CRGB::Red;
leds[3] = CRGB::Red;
leds[4] = CRGB::Red;
leds[5] = CRGB::Red;
leds[6] = CRGB::Red;
leds[7] = CRGB::Red; //for loop
FastLED.show();
FastLED.setBrightness(30);
delay(500);

leds[0] = CRGB::Blue;
leds[1] = CRGB::Blue;
leds[2] = CRGB::Blue;
leds[3] = CRGB::Blue;
leds[4] = CRGB::Blue;
leds[5] = CRGB::Blue;
leds[6] = CRGB::Blue;
leds[7] = CRGB::Blue;

FastLED.show();
delay(500);
*/
} else {

if (final_score == 0) {
// set it once and for all
final_score = moisture_percentage;
}

if (final_score < 50.00) {
leds[0] = CRGB::Red;
leds[1] = CRGB::Red;
leds[2] = CRGB::Red;
leds[3] = CRGB::Red;
leds[4] = CRGB::Red;
leds[5] = CRGB::Red;
leds[6] = CRGB::Red;
leds[7] = CRGB::Red;
FastLED.show();
}
if (final_score > 50.00) {
leds[0] = CRGB::Blue;
leds[1] = CRGB::Blue;
leds[2] = CRGB::Blue;
leds[3] = CRGB::Blue;
leds[4] = CRGB::Blue;
leds[5] = CRGB::Blue;
leds[6] = CRGB::Blue;
leds[7] = CRGB::Blue;
FastLED.show();
}
if (millis() > 20000 && millis() < 23000) {
tone(8, 262);
}
if (millis() > 23000) {
noTone(8);
}
}
}

CONCLUSIONS

We want to design a fun racing game. I think the overall effect is good. Although there are still some places to improve, such as the danger of water leaking out and touching the wires, and the fact that the bottles are easy to break and need to be replaced frequently, it is very interactive and brings joy to everyone. What’s more, the project can detect basement leaks after modifications to play practical use.

Through this work, I not only have a better understanding of Arduino code (I understand the principles of fastLED programming and can use tone (), millis (), and other functions). It also improves my practical ability. For instance, I used an electric drill for the first time and made many perfect circles. Most importantly, I learned how to solve problems with my partner through brainstorming. Sometimes a change of direction can lead to a change of scenery. 

Attached below are our finished product presentation video and a highlight video of gohai and Eric’s competition.😏

Leave a Reply

Your email address will not be published. Required fields are marked *