Janessa Labeur
Published © LGPL

LumBox

A fun and safe box for your kids to play with. Get your kids off their phones and get busy!

BeginnerShowcase (no instructions)12 hours1,075
LumBox

Things used in this project

Story

Read more

Schematics

The circuit

This is the circuit, how it is put into the box. I recomend using larger wires and even better, labeled wires

Code

LumBox

Arduino
The box is designed as a dice. The ledrings light up one at a time. When they do the belonging button is pressed and u point is added. After a minute the game starts over and you can play again and try to beat your personal record.
// include the library code:
#include <Adafruit_NeoPixel.h>
#include <LiquidCrystal_I2C.h>


int buttonPin = 8;     // the number of the pushbutton pin
int PIN = 2;           

Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800);

// constants won't change. They're used here to set pin numbers:
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
// The LCD constructor - address shown is 0x27 - may or may not be correct for yours
// Also based on YWRobot LCM1602 IIC V1
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); 

// variables will change:
int buttonState;         // variable for reading the pushbutton status
int historicState;
int randNumber;
int score = 0;

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Lets play a game!");
  //lcd.display();
  delay(500);
  pinMode(buttonPin, INPUT);
  Serial.begin(9600);
  randomSeed(analogRead(0));
  
}

void loop() {
  // Turn off the display:
  //lcd.noDisplay();
  //delay(500);
  // Turn on the display:
  //lcd.display();
  //delay(500);
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);
  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
        //delay(1000);
      score++;
      lcd.clear();
      //lcd.display();
      lcd.print("Highscore: " + String (score));
      //lcd.display();
      strip = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800);
      strip.begin();
      for(int i = 0; i < 12; i++){
        strip.setPixelColor(i, 0, 0, 0);
        strip.show();
        }
      randNumber = random(2, 8);
      Serial.println(randNumber);
      PIN = randNumber;
      buttonPin = randNumber + 6;
      strip = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800);
      strip.begin();
      historicState = HIGH;
        for(int i = 0; i < 12; i++){
        strip.setPixelColor(i, 255, 0, 0);
        strip.show();
      
    }
    //Serial.println("buttonPin = " + String(buttonPin));
    delay(50);
  }
  delay(50);
}

Credits

Janessa Labeur
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.