Things used in this project

Hardware components:
Ardgen mega
Arduino Mega 2560 & Genuino Mega 2560
×1
7 segment display
×1
arduino kaypad 3x4
×1
11026 02
Jumper wires (generic)
×1
mini battery display
×1
Software apps and online services:
Ide web
Arduino IDE

Schematics

arduino kaypad
Arduino and keypad bb phwgoluci4
7 segment dispaly
22222 ljsnbdu1sc

Code

Arduino codeArduino
#include <Keypad.h>
#include<TM1651.h>

int CLK = 10;
int DIO = 9;
TM1651 batteryDisplay(CLK,DIO);
const byte ROWS = 4; 
const byte COLS = 3;
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
byte rowPins[ROWS] = {8, 7, 6, 5}; 
byte colPins[COLS] = {4, 3, 2};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

int start[7]={39,41,53,49,47,37,35};
int ugasi[7]={0,0,0,0,0,0,0};
int jedan[7]={0,1,1,0,0,0,0};
int dva[7]={1,1,0,1,1,0,1};
int tri[7]={1,1,1,1,0,0,1};
int cetiri[7]={0,1,1,0,0,1,1};
int pet[7]={1,0,1,1,0,1,1};
int sest[7]={0,0,1,1,1,1,1};
int sedam[7]={1,1,1,0,0,0,0};
int osam[7]={1,1,1,1,1,1,1};
int devet[7]={1,1,1,0,0,1,1};
int nula[7]={1,1,1,1,1,1,0};
int pom=0;
int s[50];
int k=0;
int partija=0;

void setup(){
  Serial.begin(9600);
  Output(start);
  batteryDisplay.init();
  batteryDisplay.set(BRIGHTEST);//BRIGHT_TYPICAL = 2,BRIGHT_DARKEST = 0,BRIGHTEST = 7;
  batteryDisplay.frame(FRAME_ON);
  randomSeed(analogRead(0));

  while(partija!=8){
    batteryDisplay.displayLevel(partija);
    s[k]=random(0,10);
    WriteDisplay(start,ugasi);
    delay(200);
    ispisi(s[k]);
    if(Konacno(k)!=0){
        WriteDisplay(start,ugasi);
        break;
     }
     partija++;k++;
  }//while end
}//setup end
  
void loop(){}

int Konacno(int k){
  int pom=0;
  while(pom<=k){
     char key = keypad.getKey();
     while(!key){ key = keypad.getKey(); }
     if(s[pom]!=K(key)) return -1;
     pom++;
     delay(400);
  }
  return 0;
}//end konacno
int K(char key){
  if(key=='1')return 1;
  else if(key=='2')return 2;
  else if(key=='3')return 3;
  else if(key=='4')return 4;
  else if(key=='5')return 5;
  else if(key=='6')return 6;
  else if(key=='7')return 7;
  else if(key=='8')return 8;
  else if(key=='9')return 9;
  else if(key=='0')return 0;
  else if(key=='*')return 10;
  else if(key=='#')return 11;
}

void ispisi(int x){
  switch(x){
    case 1:{ WriteDisplay(start,jedan); break; }
    case 2:{ WriteDisplay(start,dva); break; }
    case 3:{ WriteDisplay(start,tri); break; }
    case 4:{ WriteDisplay(start,cetiri); break; }
    case 5:{ WriteDisplay(start,pet); break; }
    case 6:{ WriteDisplay(start,sest); break; }
    case 7:{ WriteDisplay(start,sedam); break; }
    case 8:{ WriteDisplay(start,osam); break; }
    case 9:{ WriteDisplay(start,devet); break; }
    case 0:{ WriteDisplay(start,nula); break; }
  }
}
void WriteDisplay(int start[], int niz[]){
  for(int i=0;i<7;i++){
    if(niz[i]==0)digitalWrite(start[i],LOW);
    else digitalWrite(start[i],HIGH);
  }
}
void Output(int start[]){
  for(int i=0;i<7;i++){
    pinMode(start[i],OUTPUT);
  }
}
 
 
 

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Water Softener
Easy
  • 141
  • 5

Full instructions

Sweeping frequency magnetic hard water conditioner

Simple Obstacle Senor With Arduino
Easy
  • 41
  • 2

Full instructions

I am Gonna show you how to make a Simple obstacle sensing system with cheap parts like IR led and Photo diode.

Safe City: A Device to Keep You Safe
Easy
  • 440
  • 5

Full instructions

The device will keep you safe. Just have to click a button and your precise location will be shared.

Know the Temp of Your Home From Anywhere with Arduino Cloud!
Easy
  • 763
  • 7

Full instructions

Ever wanted to know the temperature of your home from somewhere? Here's an easy way to do it with Arduino Cloud and the Yun Shield!

Connect Your Thinxtra Xkit Using Sigfox
Easy
  • 117
  • 2

Protip

Learn how to build an IoT application over Sigfox integrated with Ubidots - send temp readings based on motion sensors.

Scavenger Hunt Clues w/ Telephone Keypad
Easy
  • 852
  • 3

Full instructions

Type the correct code on the phone's keypad to hear the clue through the handset, then decode the message to finish before the other team.

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaFree StoreBlog