Hackster is hosting Impact Spotlights: Industrial Automation. Watch the stream live on Thursday!Hackster is hosting Impact Spotlights: Industrial Automation. Stream on Thursday!
Vanessa Benavidez
Created August 10, 2021 © MIT

Smart Toy Box

Smart toy box to make cleaning up fun.

Smart Toy Box

Things used in this project

Story

Read more

Schematics

Toy Box Fritzing

Toy Box Schematics

Code

Smart Toy Box Code

C/C++
/*
   Project: Smart_Room_Controller
   Description: Smart Toy Box
   Author: Vanessa Benavidez
   Date: June 29-21
*/

#include <Adafruit_NeoPixel.h>
#include <colors.h>
#include <OneButton.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Ethernet.h>
#include <mac.h>
#include <SPI.h>
#include <SPI.h>
#include <hue.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET     4
#define SCREEN_ADDRESS 0x3C
const int PIXELPIN = 17;
const int PIXELCOUNT = 14;
const int BUTTONPIN = 23;
const int bri = 15;
int pixelOn = true;
int i;
bool buttonState;
bool stateChange;
OneButton button1(BUTTONPIN, false);

Adafruit_NeoPixel pixel(PIXELCOUNT, PIXELPIN, NEO_GRB + NEO_KHZ800);
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
EthernetClient Wemoclient;
int wemoPort = 49153;
bool status;


void setup() {

  Serial.begin(9600);
  buttonState = false;

  if (!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;); // Don't proceed, loop forever
  }
  display.display();
  delay(2000);
  display.clearDisplay();
  display.drawPixel(10, 10, SSD1306_WHITE);
  display.display();
  //pinMode (BUTTONPIN, INPUT);
  Ethernet.begin(mac);
  delay(200);          //ensure Serial Monitor is up and running
  //printIP();
  Serial.printf("LinkStatus: %i  \n", Ethernet.linkStatus());
  pixel.begin();
  pixel.show();
  button1.attachClick (click1);
  //  button1.attachDoubleClick (doubleclick1);
}

void loop() {
  button1.tick();
  if (buttonState == true) {
    pixel.fill(0xFF0000, 0, 14);
    //delay(100);
    pixel.setBrightness(bri);
    pixel.show();
    Serial.printf("Button status %i\n", buttonState );


    display.clearDisplay();
    display.setTextSize(3);
    display.setTextColor(SSD1306_WHITE);
    display.setCursor(0, 0);
    display.println(F("TIME TO CLEAN UP MAX "));

    display.display();

    setHue(1, true, HueRed, 255, 255);
    setHue(2, true, HueRed, 255, 255);
    setHue(3, true, HueRed, 255, 255);
    setHue(4, true, HueRed, 255, 255);
    setHue(5, true, HueRed, 255, 255);
  }

  else {

    setHue(1, true, HueBlue, 255, 255);
    setHue(2, true, HueBlue, 255, 255);
    setHue(3, true, HueBlue, 255, 255);
    setHue(4, true, HueBlue, 255, 255);
    setHue(5, true, HueBlue, 255, 255);

    pixel.clear();
    pixel.show();

    display.display();
    display.clearDisplay();
    display.setTextSize(3);
    display.setTextColor(SSD1306_WHITE);
    display.setCursor(0, 0);
    display.println(F("GOOD JOB MAX :) "));


  }



  Serial.printf("Button status %i\n", digitalRead(BUTTONPIN));


}

void click1 () {
  buttonState = !buttonState;
  Serial.printf("Button status %i\n", buttonState );


}


//void doubleclick1 () {
//  stateChange = !stateChange;
//
//}

Credits

Vanessa Benavidez
3 projects • 1 follower
Contact

Comments

Please log in or sign up to comment.