asdf13424rfwe
Published © GPL3+

Riddle Keypad Project (TEJ3M Summative)

Summative Project for TEJ3M

IntermediateShowcase (no instructions)1,152
Riddle Keypad Project (TEJ3M Summative)

Things used in this project

Hardware components

Keypad
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×8
Jumper wires (generic)
Jumper wires (generic)
×4
Sunfounder Lcd
×1
Arduino UNO
Arduino UNO
×1

Software apps and online services

Tinkercad
Autodesk Tinkercad
Dremel DigiLab 3D Slicer
Arduino IDE
Arduino IDE

Story

Read more

Custom parts and enclosures

summative_(keypad_case)_n26DwQWHUh.stl

Schematics

Diagram

Code

Riddle Keypad Code

Arduino
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <Keypad.h> //includes all the libraries

#define Password_Length 5 //sets the length of the password
int signalPin = 12; //
 
char Data[Password_Length]; 
char Master[Password_Length] = "3.14"; //sets password
byte data_count = 0, master_count = 0;
bool Pass_is_good;
char customKey;

const byte ROWS = 4; 
const byte COLS = 4;

char hexaKeys[ROWS][COLS] = {
  {'1', '4', '7', '#'},
  {'2', '5', '8', '0'}, //tells the computer which button is which value
  {'3', '6', '9', '.'},
  {'A', 'B', 'C', 'D'}
};

byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};

Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);


LiquidCrystal_I2C lcd(0x27, 16, 2);//tells the computer the dimensions of the lcd

void setup(){
  lcd.init(); 
  lcd.backlight();
}

void loop(){

  lcd.setCursor(0,0);
  lcd.print("What do math");
  lcd.setCursor(0,2);
  lcd.print("teachers eat?"); //Displays the question
  
  
  customKey = customKeypad.getKey();
  if (customKey){
    Data[data_count] = customKey;;
    lcd.setCursor(14,1); 
    lcd.print(Data[data_count]); 
    data_count++;
    } // displays the button being pressed as you press it

  if(data_count == Password_Length-1){
    delay(500);
    lcd.clear();

    if(!strcmp(Data, Master)){
      lcd.print("    Unlocked!");
      delay(3000);
      } // if the password is right, print unlocked...
    else{
      lcd.print("    Try again!");
      lcd.setCursor(0,2);
      lcd.print("Hint: Dessert");
      delay(2000); //...if not, say try again and give a hint
      }
    
    lcd.clear();
    clearData();  //clear everything on the screen and set data_count back to 0
  }
}

void clearData(){
  while(data_count !=0){
    Data[data_count--] = 0; 
  }
  return;
}

Credits

asdf13424rfwe

asdf13424rfwe

0 projects • 0 followers

Comments