Master & Mind 's
The story
It's crazy how things happen naturally when it has to happen.
This project was made for this contest but the sparkle came from a complete different source. It started in May when in our hackerspace somebody asked me to try something with a stepper from a DVD player (So basically something like https://www.instructables.com/id/Dvd-Stepper-Motor-Arduino/). As I don't like to just redo what was done, I always try to combine with other things. So I open my toolbox and try to find something to combine with and I had still this color sensor in its new packaging. I decided to use this color sensor : depending on the color detected move the stepper in different positions.
Great, it's quite easy and it works well but what to do with that ? And then, while fine tuning and looking for a target to this circuit, I finally found THE idea and quite in the same time the Instructables rainbow contest.
So here was born the M&Ms distibutor with a mastermind logic to get the sweets. For time and skills reasons, we work at 2 on this project only 4 Thursday evenings in common and some personal work during the weed-end.
After some iterations, the final version consist of a buffer that is feed with 3 or 4 sweets and a color sensor that analyses the color sequence. Then a rotary encoder can be used to set different color sequences on RGB LEDs strip and the other LEDs can tell you how far you are from the right sequence.
When the sequence is right, the buffer can release the sweets to the players. This gameplay can also change in the future such as 2 players or with a timer so that if you are wrong you don't get the sweets (they'll go in another way).
So after 4 or 5 evenings with intensive work, here we are at the end of the time allowed for this contest : the mechanism is working, the code is well working for sensors, leds, encoder and steppers. But the color sensor just died after the last unsolding/solding session.
So I won't be able to present here the MasterMind working, but the project is still nice just like that and can be upgraded later. You can also start with this project and adapt your personal gameplay as you want. For example you can program the MasterMind game but you can also program a Candy Crush game or any simple game for one or two players that will reward the winner with sweets :D
Downloads
Supplies
- 1 stepper with ULN2003 Driver
- 1 servo motor
- 1 color sensor
- 1 rotary encoder
- 1 RGB led strip
- 1 postion switch
- 1 Push Button
- 1 3D printer
- 1 Laser cutting device
- 1 CNC
- 1 MDF board
- 30cm long and 8cm diameter plexiglas tube
The Different Parts
The upper bin : made with the Plexi tube, the plug is 3D printed and it's mounted on the collector with 3 aluminium rods.
The collector : it's 3d printed and laser cut.
- On the top, you have a 3D printed funnel with a hole for one MMS.
- Then you have the moving part 3D printed with a steel agitator that goes through the funnel (to help the MMs moving in the bin)
- The bottom slice hold the stepper and the Switch.
- The outside ring is made from laser cut rings (in black plexiglas to hide the MMs color that you pick.
- When you start the arduino, the stepper move slowly back until he reaches the switch. Then you know the 0 position and you can calibrate the total range of moving from "collecting point" to "buffer entry".
The Buffer, 3D printed : it's where the MMs are stored before being released by the game
- The Color sensor is bolt on the up of the buffer (The MMs fall on the sensor where you determine the color)
- The buffer is surrounded by laser cut rings and it's where you store the ULN2003 driver and you collect all cables together
The ejector is made of a upper plate (holding the servo), the moving part 3D printed and the bottom plate.
The servo have 3 positions : in the middle (45°), the servo collect the sweet from the buffer. Then the 2 opposite sides (around 0° and 90° to be calibrated) can eject either in the winning ramp, either in the loosing bucket.
The bottom part is made from the second part of the plexiglass tube (for the loosing bucket), a MDF plate curved for MMs collected and the Arduino + Led Strips + Rotary encoder.
So the shared code is only for moving parts and use of rotary encoder and led strips from Adafruit. The game himself is not yet program. Basically, it will consist of an array of 3 or 4 values corresponding to colors measured that you'll have to recover by changing Led color (so color value) on your led strip with the rotary encoder. When you rotate, the color change and when you push the rotary encoder button, you switch to the next led (so the next value in the array).
You'll find everything files needed in the .zip attached and the code in the .ino attached.
You need of course to print all the pieces and cut all the rings with a laser cutter.
You can make the bottom board easier than with a CNC.
Then you can download the Arduino code and program the interaction by calling different functions :
sensorColorRead() will return different value for different color.
encoder() will set the led strip.