|
Arduino Nano |
x 1 | |
|
Linear Potentiometer 10k Ohms |
x 3 | |
|
Resistor 47k Ohms |
x 3 | |
|
Analog V.U. (15V) |
x 3 | |
|
Resistor 150 Ohms |
x 3 | |
|
Led Blue |
x 1 | |
|
Led Red |
x 1 | |
|
Led Green |
x 1 |
The Crazy Pots Game
At some point on the internet I came across someone who had made a game like that, but unfortunately, I missed the bookmark. So I decided to make my version, basing myself a bit on what I remembered the little game I saw.
The game consists of calibrating the three V.U.s using the three potentiometers. It sounds like a cinch, but with each round, the pots are drawn. So without always the blue potentiometer will move the V.U pointer. with the Blue Led. And yet, not always the pointer of the V.U. and the potentiometer move in the same direction. You have 15 seconds to find the calibration or the system restarts and replaces all the positions. There are 48 different possibilities!
The LEDs are connected to the digital pins 6, 7 and 8 through resistors to limit the current (I used three of 220 Ohms).
Then I connected the positive of the V.U.s in the outputs PWM 9, 10, and 11 the negative in GND.
I also made another call in the U.S., this time to monitor their voltages: Pins 3, 4 and 5. This step was very important here and I could only solve with the help of this link here:
That way I can tell what voltage is being displayed in the V.U. , since the potentiometers will always change position and direction.
Finally, I connected the potentiometers to the analog inputs A5, A6 and A7.
I'm using pin A0 as the seed of my random numbers.
Also, pins 12 and 13 like Buzzer and Relay.
/** App: THE CRAZY POTS Desenvolvido por: Djair Guilherme (Nicolau dos Brinquedos) Usando ARDUINO NANO Abril de 2018 +-----+ +------------| USB |------------+ | +-----+ | B5 | [ ]D13/SCK MISO/D12[ ] | B4 | [ ]3.3V MOSI/D11[ ]~| B3 | [ ]V.ref ___ SS/D10[ ]~| B2 C0 | [ ]A0 / N \ D9[ ]~| B1 C1 | [ ]A1 / A \ D8[ ] | B0 C2 | [ ]A2 \ N / D7[ ] | D7 C3 | [ ]A3 \_0_/ D6[ ]~| D6 C4 | [ ]A4/SDA D5[ ]~| D5 C5 | [ ]A5/SCL D4[ ] | D4 | [ ]A6 INT1/D3[ ]~| D3 | [ ]A7 INT0/D2[ ] | D2 | [ ]5V GND[ ] | C6 | [ ]RST RST[ ] | C6 | [ ]GND 5V MOSI GND TX1[ ] | D0 | [ ]Vin [ ] [ ] [ ] RX1[ ] | D1 | [ ] [ ] [ ] | | MISO SCK RST | | NANO-V3 | +-------------------------------+ http://busyducks.com/ascii-art-arduinos */ #define DEBUG // Led Pins #define blue 6 #define yellow 7 #define red 8 // Vu meters #define left 9 #define center 10 #define right 11 // Potentiometers #define bpot A7 #define ypot A6 #define rpot A5 // The readings of pins 3, 4 and 5 will detect correct number // Connected to Vu meters, convert PWM readings into Analog Reading #define read0 3 #define read1 4 #define read2 5 // Outputs #define buzzer 12 #define relay 13 // Time for clue #define timeclue 1000 //Winning Numbers 935 #define winner0 10 #define winner1 5 #define winner2 7 unsigned long ultimaRodada = 0; unsigned long tempoRodada = 15000; // Array tha contains pin numbers int led[3] = {blue, yellow, red}; // Blue, Yellow, Red int vu[3] = {left, center, right}; int pot[3] = {bpot, ypot, rpot}; int readings[3] = {read0, read1, read2}; int winner[3] = {winner0, winner1, winner2}; int pot0, pot1, pot2; int out0, out1, out2; const byte inactive [2] = {1, 2}; // To follow puzzle States enum PuzzleState {Initialising, Running, Solved}; PuzzleState puzzleState = Initialising; bool lastState = false; int sensorValue = 0; int outputValue = 0; void setup() { for (int i = 0; i < 3; i++) { pinMode(led[i], OUTPUT); pinMode(vu[i], OUTPUT); pinMode(readings[i], INPUT); } // Avoiding noises!!! for (int j = 0; j < 9; j++) { pinMode(inactive [j], INPUT_PULLUP); } pinMode (relay, OUTPUT); randomSeed (analogRead(0)); #ifdef DEBUG Serial.begin(9600); Serial.println(F("Starting Serial Communication... SETUP")); #endif digitalWrite (blue, LOW); digitalWrite (yellow, LOW); digitalWrite (red, LOW); puzzleState = Running; } void loop() { digitalWrite (relay, LOW); maxMinVu (0); delay (500); setLed (HIGH, LOW, LOW); analogWrite (left, 255); delay(timeclue); setLed (LOW, HIGH, LOW); analogWrite (center, 255); delay(timeclue); setLed (LOW, LOW, HIGH); analogWrite (right, 255); delay(timeclue); maxMinVu(0); ultimaRodada = millis(); int choice = random (1, 48); // 48 probabilities! while ((millis() - ultimaRodada < tempoRodada)) { sorteio (choice); // reading VU values and Map it to numbers 0 to 10 ?int number0 = map (readPWM(read0), 0, 1023, 0, 10); int number1 = map (readPWM(read1), 0, 1023, 0, 10); int number2 = map (readPWM(read2), 0, 1023, 0, 10); //Detect if evaluated numbers are the winners!; if (evaluate (number2, number1, number0)) { onSolve(); delay(10000); } else if (!evaluate) { onUnsolve(); } } Serial.println ("Next round"); } // Here are the custom functions: void maxMinVu(int flag) { if (flag == 0) { setLed (LOW, LOW, LOW); analogWrite (left, 0); analogWrite (center, 0); analogWrite (right, 0); } else if (flag == 1) { analogWrite (left, 255); analogWrite (center, 255); analogWrite (right, 255); } } void normal (int sense, int vumeter) { // Pot and VU at same directionint ?potentiometro = analogRead(sense); int saida = map (potentiometro, 1023, 0 , 0, 255); analogWrite (vumeter, saida); } void reverso (int sense, int vumeter) { // Pot and VU are reversedint ?potentiometro = analogRead(sense); int saida = map (potentiometro, 0, 1023 , 0, 255); analogWrite (vumeter, saida); } void setLed (int stateBlue, int stateYellow, int stateRed) { // Led is on if Pot and VU matches digitalWrite (blue, stateBlue); digitalWrite (yellow, stateYellow); digitalWrite (red, stateRed); } int readPWM(int digitalPin) { // Detect PWMint ?var = pulseIn (digitalPin, HIGH, 4200); if (var == 0 && digitalRead (digitalPin) == 1) { var = 2100; } var = map (var, 0 , 2100, 0, 1023); return var; } bool evaluate (int num0, int num1, int num2) { // Evaluate Results to detect Winner: #ifdef DEBUG Serial.print (num0); Serial.print (" "); Serial.print (num1); Serial.print (" "); Serial.println (num2); Serial.println ("-----"); #endif if (num0 == winner[0] && num1 == winner[1] && num2 == winner[2]) { return true; } else if (num0 != winner[0] || num1 != winner[1] || num2 != winner[2]) { return false; } } void onSolve() { // Aciona o relê se o quebra-cabe?a foi resolvido digitalWrite (relay, HIGH); #ifdef DEBUG Serial.println(F("Quebra Cabeca Resolvido!")); #endif// E toca cinco bipes!for (int i = 0; i < 5; i++) { tone (buzzer, 2500, 1000); setLed (HIGH, HIGH, HIGH); delay(200); noTone(buzzer); setLed (LOW, LOW, LOW); delay(200); } puzzleState = Solved; } void onUnsolve() { #ifdef DEBUG//Serial.println(F("Quebra Cabeca Desmanchado!")); #endif puzzleState = Running; } void sorteio (int choice) { // Aqui s?o 48 possibilidades!!! ?switch (choice) {case 1: normal (bpot, left); normal (ypot, center); normal (rpot, right); setLed (HIGH, HIGH, HIGH); break; case 2: normal (bpot, left); normal (ypot, right); normal (rpot, center); setLed (HIGH, LOW, LOW); break; case 3: normal (bpot, right); normal (ypot, center); normal (rpot, left); setLed (LOW, HIGH, LOW); break; case 4: normal (bpot, right); normal (ypot, left); normal (rpot, center); setLed (LOW, LOW, LOW); break; case 5: normal (bpot, center); normal (ypot, left); normal (rpot, right); setLed (LOW, LOW, HIGH); break; case 6: normal (bpot, center); normal (ypot, right); normal (rpot, left); setLed (LOW, LOW, LOW); break; case 7: reverso (bpot, left); normal (ypot, center); normal (rpot, right); setLed (HIGH, HIGH, HIGH); break; case 8: reverso (bpot, left); normal (ypot, right); normal (rpot, center); setLed (HIGH, LOW, LOW); break; case 9: reverso (bpot, right); normal (ypot, center); normal (rpot, left); setLed (LOW, HIGH, LOW); break; case 10: reverso (bpot, right); normal (ypot, left); normal (rpot, center); setLed (LOW, LOW, LOW); break; case 11: reverso (bpot, center); normal (ypot, left); normal (rpot, right); setLed (LOW, LOW, HIGH); break; case 12: reverso (bpot, center); normal (ypot, right); normal (rpot, left); setLed (LOW, LOW, LOW); break; case 13: normal (bpot, left); reverso (ypot, center); normal (rpot, right); setLed (HIGH, HIGH, HIGH); break; case 14: normal (bpot, left); reverso (ypot, right); normal (rpot, center); setLed (HIGH, LOW, LOW); break; case 15: normal (bpot, right); reverso (ypot, center); normal (rpot, left); setLed (LOW, HIGH, LOW); break; case 16: normal (bpot, right); reverso (ypot, left); normal (rpot, center); setLed (LOW, LOW, LOW); break; case 17: normal (bpot, center); reverso (ypot, left); normal (rpot, right); setLed (LOW, LOW, HIGH); break; case 18: normal (bpot, center); reverso (ypot, right); normal (rpot, left); setLed (LOW, LOW, LOW); break; case 19: reverso (bpot, left); reverso (ypot, center); normal (rpot, right); setLed (HIGH, HIGH, HIGH); break; case 20: reverso (bpot, left); reverso (ypot, right); normal (rpot, center); setLed (HIGH, LOW, LOW); break; case 21: reverso (bpot, right); reverso (ypot, center); normal (rpot, left); setLed (LOW, HIGH, LOW); break; case 22: reverso (bpot, right); reverso (ypot, left); normal (rpot, center); setLed (LOW, LOW, LOW); break; case 23: reverso (bpot, center); reverso (ypot, left); normal (rpot, right); setLed (LOW, LOW, HIGH); break; case 24: reverso (bpot, center); reverso (ypot, right); normal (rpot, left); setLed (LOW, LOW, LOW); break; case 25: normal (bpot, left); normal (ypot, center); reverso (rpot, right); setLed (HIGH, HIGH, HIGH); break; case 26: normal (bpot, left); normal (ypot, right); reverso (rpot, center); setLed (HIGH, LOW, LOW); break; case 27: normal (bpot, right); normal (ypot, center); reverso (rpot, left); setLed (LOW, HIGH, LOW); break; case 28: normal (bpot, right); normal (ypot, left); reverso (rpot, center); setLed (LOW, LOW, LOW); break; case 29: normal (bpot, center); normal (ypot, left); reverso (rpot, right); setLed (LOW, LOW, HIGH); break; case 30: normal (bpot, center); normal (ypot, right); reverso (rpot, left); setLed (LOW, LOW, LOW); break; case 31: reverso (bpot, left); normal (ypot, center); reverso (rpot, right); setLed (HIGH, HIGH, HIGH); break; case 32: reverso (bpot, left); normal (ypot, right); reverso (rpot, center); setLed (HIGH, LOW, LOW); break; case 33: reverso (bpot, right); normal (ypot, center); reverso (rpot, left); setLed (LOW, HIGH, LOW); break; case 34: reverso (bpot, right); normal (ypot, left); reverso (rpot, center); setLed (LOW, LOW, LOW); break; case 35: reverso (bpot, center); normal (ypot, left); reverso (rpot, right); setLed (LOW, LOW, HIGH); break; case 36: reverso (bpot, center); normal (ypot, right); reverso (rpot, left); setLed (LOW, LOW, LOW); break; case 37: normal (bpot, left); reverso (ypot, center); reverso (rpot, right); setLed (HIGH, HIGH, HIGH); break; case 38: normal (bpot, left); reverso (ypot, right); reverso (rpot, center); setLed (HIGH, LOW, LOW); break; case 39: normal (bpot, right); reverso (ypot, center); reverso (rpot, left); setLed (LOW, HIGH, LOW); break; case 40: normal (bpot, right); reverso (ypot, left); reverso (rpot, center); setLed (LOW, LOW, LOW); break; case 41: normal (bpot, center); reverso (ypot, left); reverso (rpot, right); setLed (LOW, LOW, HIGH); break; case 42: normal (bpot, center); reverso (ypot, right); reverso (rpot, left); setLed (LOW, LOW, LOW); break; case 43: reverso (bpot, left); reverso (ypot, center); reverso (rpot, right); setLed (HIGH, HIGH, HIGH); break; case 44: reverso (bpot, left); reverso (ypot, right); reverso (rpot, center); setLed (HIGH, LOW, LOW); break; case 45: reverso (bpot, right); reverso (ypot, center); reverso (rpot, left); setLed (LOW, HIGH, LOW); break; case 46: reverso (bpot, right); reverso (ypot, left); reverso (rpot, center); setLed (LOW, LOW, LOW); break; case 47: reverso (bpot, center); reverso (ypot, left); reverso (rpot, right); setLed (LOW, LOW, HIGH); break; case 48: reverso (bpot, center); reverso (ypot, right); reverso (rpot, left); setLed (LOW, LOW, LOW); break; } }
The Crazy Pots Game
- Comments(0)
- Likes(0)
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by nicolaudosbrinquedos
- Homeassistant in Beaglebone Black With Debian 11 Intro: The primary objective of my project was to give some use to the Beaglebone Black that has bee...
- The Adventures of Porting Circuitpython to Wio RP2040 I have been developing some electronic props solutions for Escape Rooms. And periodically I usually ...
- Simple Electronics to Escape Room Owners - Using a bunch of voltmeters with PCA9685 This is a preliminary study for an Escape Room game. My main goal was to add as many analog displays...
- Simple Electronics to Escape Room Owners - First Chapter I've been developing puzzles and artifacts for Escape Room since 2018 and most of the time, I've bee...
- Finally! Animated Eyes using Seed Xiao RP2040 This is another advance in my studies to enable a more economically viable version for the Monster M...
- Circuitpython on Seeed XIAO RP2040 Step 1: Unboxing... I2C Not Working?As soon as the card arrived, I installed the firmware version fo...
- Raspberry Pi Pico with GC9A01 Round Display using Arduino IDE and TFT-eSPI Library This is a work in progress for another one of the artifacts I used in Leonardo Cortez's "Strange Hou...
- Recreating an 80s TV with Raspberry Pi Recently I built a series of special effects for the scenography of the play "Strange House" by Leon...
- Talk to Me This project is part of an extensive research on the use of animatronics and interactive objects tha...
- Back in time! Make a Zoetrope using Arduino I'm working on a series of animated objects for a children's play and decided to build a Zoetrope, t...
- Alastor Moody Eye using Raspberry Pi Pico, CircuitPython and Round Display GC9A01 I am developing a series of objects for a children's play about fear and terror. And then I got insp...
- The Crazy Pots Game At some point on the internet I came across someone who had made a game like that, but unfortunately...
- Arduino Mastermind Game I created this little game as a hobby for my children during the Covid-19 quarantine. I had already ...
- Raspberry Pi Pico With I2C Oled Display and CircuitPython This is my first experience using this little board from Raspberry Pi Foundation.I preferred to inst...
- Raspberry Pi Pico and TFT ILI9341 with Circuit Python I decided to write another tutorial on the Raspberry Pi Pico, mainly because the card is very recent...
- Arduino Minesweeeper It was then that I found the works of Rachit Belwariar, on the page https://www.geeksforgeeks.org/cp...
-
-
-
-
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
154 1 1 -
-