Bonjour amigo's
I am working on a new project that I need help with, I am prototyping a new setup for a big wheel Lotto game. It features a wheel of RGB's 24 of them, and 8 RGB's in a wheel inside the large wheel of 24. The Purpose of the game is to make a selection from the 8 RGB Wheel and then press spin to make the RGB's in the outer larger wheel go around in a circle more than 5 times and then coming to a stop at a random spot in the wheel that is compared to the 1 in 8 selected. If the number reduced to 8ths match then you win.
Here is my wiring schematic.
and here is my code so far.
/* This Project is a big Led light wheel with a smaller led light wheel in the center.
* the big wheel has 24 RGB's and the inner "selection" wheel has 8 RGB's
* the point is to select a RGB with a Pot in the inner smaller ring
* and have it match or try to match the end of the loop of LED's
* when they stop at a random place. So if user selects place number 5 for example
* then they need the wheel to stop at place 12 trough 15 in the outer ring.
* I will be adding a third strand of RGB's to add some flare to getting a match
* or not getting a match. I would like the outer RGB Ring to go around at least
* 5 times before having a random number from 1 to 24 multiply lets say another
* 3 times around so it will reach a random spot on every spin. THen a button resets the
* action. So the pot selects from 1 to 8 and the first button begins the leds in the outer ring
* going round and then they are brought to a stop at a random location that is compared
* to the user selected number in the first ring of 1 to 8. Each number from 1 to 8 in the
* inner ring has 3 spots on the outer ring that would be a match, so it looks a little like a dart board A simple game of
* guess the number with ws2812b's
*/
#include <JC_Button.h>
const byte Pin_button2 = 6;//The reset Button
const byte Pin_button3 = 5;//The spin Button
Button RESETGAME (Pin_button2);
Button SPIN (Pin_button3);
#include <pRNG.h> //randomizing library gives a random result of 0 to 255
pRNG prng;
#include <FastLED.h> //My led data pins and each Strip LED count
#define NUM_LEDS 8
#define DATA_PIN 2
#define DATA_PIN2 3
#define DATA_PIN3 4
#define NUM_LEDS2 24
#define NUM_LEDS3 5
CRGB leds[NUM_LEDS];
CRGB leds2[NUM_LEDS2];
CRGB leds3[NUM_LEDS3];
//Declare some Gloabal Variables
int pick; //the number selected by gambler
int analogPin = 1; //the pin the analog selector is on 10k pot used
int spinIt;
int outerLEDS[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23};
void setup() {
// put your setup code here, to run once:
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); //initalize the first strand
FastLED.addLeds<NEOPIXEL, DATA_PIN2>(leds2, NUM_LEDS2); //initialie the second strand
FastLED.addLeds<NEOPIXEL, DATA_PIN3>(leds3, NUM_LEDS3); //initialie the Third strand
RESETGAME.begin();
SPIN.begin();
Serial.begin(2400);
}
void loop() {
// put your main code here, to run repeatedly:
pick = analogRead(analogPin);//the user selects a int from 1 to 1023
pick = map(pick, 0, 1023, 1, 8);//the dial is maped to 1 to 8
Serial.print("Bet Selected:");
Serial.println(pick);
selectNumber();
checkbuttons();
}
void checkbuttons() {
SPIN.read(); //read the spin button
if (SPIN.wasReleased()) outerSpin(); //initiate the spinning of the big wheel of LED's
RESETGAME.read();
if (RESETGAME.wasReleased()) resetGame();//reset the game when the button is pressed
}
int outerSpin() { //spins the outer ring of LED's would like it to do 4 circles plus a rondom 2 to 5 aditional circles and stop at a random spot
int dot = 0;
byte spinIt = prng.getRndByte(); //gets a random number to multiply the number of more Led's that cycle
spinIt = map (spinIt, 0, 255, 1, 24); //maping the random number
Serial.print("Random Number:");
Serial.print(spinIt);
for (int dot = 0; dot < NUM_LEDS2; dot++) { //makes the leds go around once, need to repeat
leds2[dot] = CRGB::Purple;
FastLED.show();
// clear this led for the next time around the loop
leds2[dot] = CRGB::Black;
delay(65);
}
}
void resetGame() { //looking to Reset all LED's and start from the begining
FastLED.clear();
FastLED.show();
}
void selectNumber() { //the code that selects the number and lights up the indicating LED
if (pick == 1) {
leds[1] = CRGB::Black;
leds[0] = CRGB::Blue;
FastLED.show();
} else if (pick == 2) {
leds[2] = CRGB::Black;
leds[0] = CRGB::Black;
leds[1] = CRGB::Blue;
FastLED.show();
} else if (pick == 3) {
leds[3] = CRGB::Black;
leds[1] = CRGB::Black;
leds[2] = CRGB::Blue;
FastLED.show();
} else if (pick == 4) {
leds[4] = CRGB::Black;
leds[2] = CRGB::Black;
leds[3] = CRGB::Blue;
FastLED.show();
} else if (pick == 5) {
leds[5] = CRGB::Black;
leds[3] = CRGB::Black;
leds[4] = CRGB::Blue;
FastLED.show();
} else if (pick == 6) {
leds[6] = CRGB::Black;
leds[4] = CRGB::Black;
leds[5] = CRGB::Blue;
FastLED.show();
} else if (pick == 7) {
leds[7] = CRGB::Black;
leds[5] = CRGB::Black;;
leds[6] = CRGB::Blue;
FastLED.show();
} else if (pick == 8) {
leds[6] = CRGB::Black;
leds[7] = CRGB::Blue;
FastLED.show();
}
}
The code needs work. I need to be able to spin through the 24 RGB strand more than 5 times and then stop randomly at any spot in the strip. Then I need to compare the result to "pick" integer and have a third light strip light green on matches and red on wrongs. When the reset button is push and its back to the start I want the third strip to Flicker on white. any thoughts or help would be great.
