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

Arduino - Web-Based Joystick
Easy
  • 503
  • 12

Full instructions

This project shows how to control devices from anywhere using web-based joystick on smartphone.

Distance Indicator Using Ultrasonic Sensor
Easy
  • 136
  • 4

Work in progress

This project lights a set of LED's depending upon the distance of the obstacle with respect to the ultrasonic sensor.

How to: IR MotionSensor
Easy
  • 43
  • 2

Protip

Learn to use an IR motion sensor with your Arduino to trigger actions on your device or robotics projects

Biped Arduino Robot
Easy
  • 80
  • 2

Full instructions

Most simple handy robot in about 2 hours!

BluSpike - Community Driven BLE Sensor Network
Easy
  • 137
  • 3

Full instructions

Easy to build w/ off the shelf parts, BLE solar powered sensor array. Connect and share its data to the cloud and be rewarded with ethereum

NeoPixel Thermometer!
Easy
  • 329
  • 5

Full instructions

Transforms a NeoPixel ring into a cool thermometer

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login