Published © CC BY-NC-SA

QuizBox - The Offline Internet Quiz

An offline internet quiz to find out what subreddit you are, who doesn't need that?

BeginnerFull instructions provided20 hours3,459

Things used in this project

Hardware components

Arduino UNO Wifi Rev.2
Arduino UNO Wifi Rev.2
×1
Toggle Switch, Toggle
Toggle Switch, Toggle
×3
Adafruit Arcade Button Red
×1
Adafruit Mini Thermal Receipt Printer
×1
5V power supply
×1
12V power supply
×1
Print paper
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Custom parts and enclosures

Base Plate

Corner

Wall

Wall with Hole

Lid

Choice Block

Name Plate

Schematics

Schematic

Code

Code

C/C++
#include "Adafruit_Thermal.h"
#include "SoftwareSerial.h"

const int TX_PIN = 6; 
const int RX_PIN = 5; 

const int buttonBigRedPin = 7;
const int switchOnePin = 8;
const int switchTwoPin = 12;
const int switchThreePin = 13;

int buttonBigRedState = 0;
int switchOneState = 0;  
int switchTwoState = 0;  
int switchThreeState = 0;

String oddlysatisfyingInfo = (
                  "                                "
                  "    --- r/oddlysatisfying ---   "
                  "                                "
                  "  Some people may call you odd, "
                  "   or even think you're fluky.  "
                  " Nonetheless, you bring your own"
                  "  unusual charm and joy to the  "
                  "         lives of many.         "
                  "                                "
                  "    --- 8 Bits and a Byte ---   "
                  "                                "
                  );
                  
String DIYInfo = (
                  "                                "
                  "          --- r/DIY ---         "
                  "                                "
                  "   Independent and resourceful. "
                  "  You are able to bring to life "
                  "  even the most ambitious ideas."

                  "                                "
                  "    --- 8 Bits and a Byte ---   "
                  "                                "
                  );
                  
String awwInfo = (
                  "                                "
                  "          --- r/aww ---         "
                  "                                "
                  "Irresistible to almost everybody" 
                  " you are the true embodiment of "
                  "     all good in this world.    "
                  "                                "
                  "    --- 8 Bits and a Byte ---   "
                  "                                "
                  );
                  
String todayilearnedInfo = (
                  "                                "
                  "     --- r/todayilearned ---    "
                  "                                "
                  "  You have an insatiable thirst "
                  "         for knowledge.         "
                  "  This means you are capable of "
                  " providing an endless stream of "
                  "   fun fact and true oddities.  " 
                  "                                "
                  "    --- 8 Bits and a Byte ---   "
                  );
                  
String funnyInfo = (
                  "                                "
                  "         --- r/funny ---        "
                  "                                "
                  "  Whenever there is fun you're  "
                  "          always near.          "
                  "Your sense of humor is unmatched"
                  "and brings comic relief to many." 
                  "                                "
                  "    --- 8 Bits and a Byte ---   "
                  "                                "
                  );
                  
String gamingInfo = (
                  "                                "
                  "        --- r/gaming ---        "
                  "                                "
                  "        A true adventurer,      "
                  "you have traveled many different" 
                  "  worlds and have lived through "
                  "        countless stories.      "
                  "                                "
                  "    --- 8 Bits and a Byte ---   "
                  "                                "
                  );

String worldnewsInfo = (
                  "                                "
                  "      --- r/worldnews ---       "
                  "                                "
                  "   Always in the know-how and   "
                  "           up-to-date,          "
                  "  your unique ability makes you "
                  "the cornerstone of this society."
                  "                                "
                  "    --- 8 Bits and a Byte ---   "
                  "                                "
                  
                  );

String artInfo = (
                  "                                "
                  "          --- r/art ---         "
                  "                                "
                  " With a distinctive personality "
                  "   and the skill set to match,  "
                  "  you have the power to create  "
                  "       beauty and to speak      "
                  "         without talking.       "
                  "                                "
                  "    --- 8 Bits and a Byte ---   "
                  "                                "
                  );

SoftwareSerial mySerial(RX_PIN, TX_PIN);
Adafruit_Thermal printer(&mySerial);


void setup() {

  mySerial.begin(19200);
  
  pinMode(7, OUTPUT); digitalWrite(7, LOW);

  printer.begin();
  printer.justify('C');  

  pinMode(buttonBigRedPin, INPUT);
  pinMode(switchOnePin, INPUT);
  pinMode(switchTwoPin, INPUT);
  pinMode(switchThreePin, INPUT);

  digitalWrite(buttonBigRedPin, HIGH);
  digitalWrite(switchOnePin, HIGH);
  digitalWrite(switchTwoPin, HIGH);
  digitalWrite(switchThreePin, HIGH);
  
}

void printSubreddit(String subreddit){
  
  printer.print(subreddit);
  
}

void printBorder(){
  
  String border = "********************************";
  printer.print(border);
  
}

void loop() {
  
  // read the state of the pushbutton value:
  buttonBigRedState = digitalRead(buttonBigRedPin);
  
  // check if the pushbutton is pressed. If it is, the buttonState is LOW:
  if (buttonBigRedState == LOW) {
    
    switchOneState = digitalRead(switchOnePin);
    switchTwoState = digitalRead(switchTwoPin);
    switchThreeState = digitalRead(switchThreePin);

    printBorder();
    
    // Print the correct answer based on all three switch states
    if(switchOneState && switchTwoState && switchThreeState){
      
      printSubreddit(oddlysatisfyingInfo);
      
    }else if(switchOneState && switchTwoState && !switchThreeState){

      printSubreddit(DIYInfo);
      
    }
    else if(switchOneState && !switchTwoState && switchThreeState){

      printSubreddit(awwInfo);
      
    }
    else if(switchOneState && !switchTwoState && !switchThreeState){

      printSubreddit(todayilearnedInfo);
      
    }
    else if(!switchOneState && !switchTwoState && !switchThreeState){

      printSubreddit(funnyInfo);
      
    }
    else if(!switchOneState && !switchTwoState && switchThreeState){

      printSubreddit(gamingInfo);
      
    }
    else if(!switchOneState && switchTwoState && !switchThreeState){
      
      printSubreddit(worldnewsInfo);
      
    }    
    else if(!switchOneState && switchTwoState && switchThreeState){
      printSubreddit(artInfo);
      
    }

    printBorder();
    printer.println("\n\n\n");
    
  } 
  
  delay(500);

}

Credits

Comments