We decided to make the game Plinko with some added twists. We have an acrylic box with a motor, three release spots and three small bins. When someone nearby makes a loud enough noise, the motor will remove the acrylic piece that was blocking the ball from falling through one of the holes. The ball will then roll down the ramp and land in one of the sections. Depending on which one it lands in, a different pattern of colors will light up the ramp.
Final Project Images:
Process Images:
Wiring Schematic:
/*
Automated Plinko Game
Elena Deng and Seema Kamath
Description: This code translates a sound above a set threshhold into motor movement which releases a ball;
once the ball hits a Force Sensitive Resistor, this code makes an LED strip light up in one
of three patterns.
Pin Mapping:
The gate on the sound detector is connected to pin 2.
The envelope on the sound detector is connected to pin A0.
The D in wire on the LED strip is connected to pin 3.
The servo motor is conncted to pin 12.
The Force Sensitive Resistors are connected to pins A1, A2, A3.
Credit:
Learned how to use the sound detector and used some of the code for setting it up and configuring the interupt from:
https://github.com/sparkfun/Sound_Detector
learned how to use the FSRs from:
https://learn.adafruit.com/force-sensitive-resistor-fsr/using-an-fsr
learned from and used code on the LED strip originally from the Polulu LED gradient demo and then customized
*/
#define PIN_GATE_IN 2 //connected to gate on sound detector
#define IRQ_GATE_IN 0
#define PIN_ANALOG_IN A0 //connected to envelope on sound detector
void soundISR()
{
int pin_val;
pin_val = digitalRead(PIN_GATE_IN);
}
#include <PololuLedStrip.h>
PololuLedStrip<3> ledStrip;
#define LED_COUNT 13
rgb_color red[LED_COUNT]; //this and the next 3 lines set up the variables for the colors on the LED strip
rgb_color surprise[LED_COUNT];
rgb_color green[LED_COUNT];
rgb_color black[LED_COUNT];
#include <Servo.h>
Servo myLittleMotor;
const int servoPin = 12;
const int fsrRightPin = A1; //fsr stands for Force Sensitive Resistor
const int fsrMiddlePin = A2;
const int fsrLeftPin = A3;
void setup() {
myLittleMotor.attach(servoPin);
Serial.begin(9600);
attachInterrupt(IRQ_GATE_IN, soundISR, CHANGE);
//the interupt ensures that the sound will be detected no matter where in the loop the program is as the noise is made
}
void loop() {
static int count = 0; //static so that once it's initiallized, it won't restart the count every loop
int soundVal;
int minSound;
int landed;
int fsrRightReading;
int REDLEDON;
int fsrMiddleReading;
int SURPRISELEDON;
int fsrLeftReading;
int GREENLEDON;
minSound = 550;
soundVal = analogRead(PIN_ANALOG_IN);
Serial.println(soundVal);
if (soundVal > minSound) {
myLittleMotor.write(0);
count = 0; //restarts the count once the motor has been triggered
}
else {
count = count + 1;
}
if (count == 500) {
myLittleMotor.write(90); //makes the motor go back into start position when the noise is below the threshold for enough time
}
fsrRightReading = analogRead(fsrRightPin);
REDLEDON = map(fsrRightReading, 0, 1023, 0, 255);
fsrMiddleReading = analogRead(fsrMiddlePin);
SURPRISELEDON = map(fsrMiddleReading, 0, 1023, 0, 255);
fsrLeftReading = analogRead(fsrLeftPin);
GREENLEDON = map(fsrLeftReading, 0, 1023, 0, 255);
//the above maps each LED color pattern variable to its respective FSR
byte time = millis() >> 2;
if (REDLEDON > 10) {
for (uint16_t i = 0; i < LED_COUNT; i++) //this rotates through each LED on the strip
{
byte x = time - i; //allows it to pulse red on and off
red[i] = rgb_color(255 - x, 0, 0);
}
ledStrip.write(red, LED_COUNT);
}
else if (SURPRISELEDON > 10) {
byte time = millis() >> 2;
for (uint16_t i = 0; i < LED_COUNT; i++)
{
byte x = time - 20 * i; //allows each LED to cycle through the surprise color pattern
surprise[i] = rgb_color(x, 0, 255 - x);
}
ledStrip.write(surprise, LED_COUNT);
}
else if (GREENLEDON > 10) {
byte time = millis() >> 2;
for (uint16_t i = 0; i < LED_COUNT; i++)
{
byte x = time - 10 * i; //allows each LED to flow through green
green[i] = rgb_color(0, 255 - x, 0);
}
ledStrip.write(green, LED_COUNT);
}
else {
byte time = millis() >> 2;
for (uint16_t i = 0; i < LED_COUNT; i++)
{
byte x = time - 10 * i;
black[i] = rgb_color(0, 0, 0);
}
ledStrip.write(black, LED_COUNT); //this turns off the LED strip as black is no color on it
}
}
Discussion:
One important thing we learned electrically was that electrical components will interact in interesting ways if there isn’t enough power provided. After making sure the sound detector and the motor worked properly separately, we combined the two as that was the first stage of our transducer. The code and the wiring was checked many times with no missteps found; however, with the motor connected, the sound detector thought the noises near it were very loud no matter the noise level. After lots of testing, we were advised to try using an outside power source for the servo motor. This thankfully solved the problem as it turned out that the amount of power the motor was drawing significantly detracted from what went to the sound detector which messed up the analog reading of it.
Design wise, the importance of having prototypes was really reiterated from this project. Our first one was a proof of concept that the double transducer could work with our components. Our second prototype was potentially going to be our final one, but it ended up being a good example of some things that we neglected to plan in our new streamlined design. One important thing was leaving a big enough gap between the ramp and the bins for the FSR wires to fit underneath. When there wasn’t a big enough gap, the FSRs were being triggered randomly from the weight of the cardboard. Additionally, it was very hard to move them and see whether or not one of the wires came loose. Moreover, we needed to make the space for the FSRs a little wider so there wouldn’t be any pressure from them touching the cardboard edges. We also made them a little thinner so that the ball would definitely land on the FSRs. Another aspect we gained from the second prototype was making a cutout in the back where we could keep the Arduino and breadboard.
Overall, the difficulties we faced were primarily from the electrical components. With the sound sensor we had difficulty managing the threshold of the sound in different spaces due to the audio differences in the environment. We also had difficulty finding a feasible library for the LED light strips, however after some assistance from Zach we were able to find the correct library and manage the colors of the strip. The “easy” parts of the project were the physical aspects of the project. Putting the laser cut pieces together and making the project look aesthetically pleasing overall was simple to do. Something we could have improved with another iteration is the placement of the panels on the ramp. We would also like to explore using the clear smoky acrylic as opposed to a sheet of paper for the ramp in the next iteration. Overall, we are happy with the way that the project turned out and the fun that we had in the process of making this triple transducer game.
Comments are closed.