Hardware components | ||||||
| × | 1 | ||||
| × | 1 | ||||
| × | 1 | ||||
| × | 2 | ||||
| × | 1 | ||||
| × | 1 |
Have you ever wondered how the ATM Machine code is written or how you press a button on the machine and the machine response to the command? I was also curious to know and that was why I did this project.
"An automated teller machine (ATM) is an electronic telecommunications device that enables customers of financial institution to perform financial transactions, such as cash withdrawals, deposits, transfer funds, or obtaining account information, at any time and without the need for direct interaction with bank staff."
This project was built to understand how the user interface of ATM machine operates.
ATM_machine_Prototype.ino
ArduinoThis code is written in the simplest form and also for newbies in Programming using Arduino to understand.
//The library used are listed below
#include <Wire.h>
#include <LiquidCrystal.h>
#include <Keypad.h>
//the datatype of variables
const byte ROWS = 4;
const byte COLS = 4;
int count = 0;
char password[2][5]= {"1234A" ,"5678B"};
int ask=0;
char key;
int choice;
int amount;
char PIN [4];
int balance = 10000;
//character hexaKeys is a multidimensional array 0f 3*4
char hexaKeys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'E','0','C'}
};
//Declaring the keypad keys as an input
byte rowPins[ROWS] ={A4, 7, 6};
byte colPins[COLS] = {2, 3, 4, 5};
Keypad keypad = Keypad(makeKeymap(hexaKeys),colPins,rowPins,COLS,ROWS);
// for the lcd pins
const int rs = 8, en = 9, d4 = 10, d5 = 11, d6 = 12, d7 = 13;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup(){
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.setCursor(0, 0);
lcd.print( " Welcome to GTBank ");
lcd.setCursor(0,0);
// for the scrolling effect of text on the lcd
for (int scrollCounter = 0; scrollCounter <12 ; scrollCounter++)
{
lcd.scrollDisplayLeft();
delay(500);
}
lcd.clear();
}
// main loop
void loop (){
// ask is the number of times for transaction to be make
while (ask=1){
lcd.setCursor(0,0);
lcd.print("Enter your pin");
delay(100);
char key = keypad.getKey();
if (key) {
lcd.setCursor ( count ,1);
delay (100);
PIN [count]=key;
lcd.print(PIN [count]);
count++ ;
if (count ==4){
delay (1000);
lcd.clear();
delay (1000);
if ( (PIN[0] == password[0][0]||PIN[0]==password[1][0]) &&( PIN[1] ==password[0][1]||PIN[1]==password[1][1]) &&
(PIN[2] == password[0][2]||PIN[2]==password[1][2]) && (PIN[3] == password[0][3]||PIN[3]==password[1][3]) )
{
lcd.print("Welcome");
delay (1000);
lcd.clear();
lcd.setCursor (0,0);
if (password[0][4])
{
lcd.setCursor(1,0);
lcd.print("Deborah");
delay(1000);
}
else {
lcd.setCursor(1,0);
lcd.print("Shade");
delay(1000);
}
// lcd.print(password[0][4]);
//delay(1000);
// lcd.clear();
//lcd.setCursor(0,0);
lcd.print( " 1- Withdrawal ");
lcd.setCursor(0,1);
lcd.print (" 2- Deposit");
delay (1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print( " 3- Balance ");
lcd.setCursor(0,1);
lcd.print(" 4- Transfer");
delay (1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" 5- Exit ");
delay(1000);
lcd.setCursor(0,0);
delay (1000);
int take= 0;
while (take<=1 ){
char key = keypad.getKey();
if (key){
if(key !=NO_KEY ){
if (key=='1'){
int amount;
int others;
lcd.clear();
lcd.setCursor(0,0);
lcd.print( "Transaction in Process ") ;
lcd.clear();
delay(1000);
lcd.setCursor(0,0);
lcd.print( " 1- #1000 ");
lcd.setCursor(0,1);
lcd.print (" 2- #2000 ");
delay (500);
lcd.setCursor(0,0);
lcd.print( " 3- #5000 ");
lcd.setCursor(0,1);
lcd.print (" 4- #10000 ");
delay (500);
lcd.setCursor(0,0);
lcd.print( " 5- #20000 ");
lcd.setCursor(0,1);
lcd.print (" 6- other ");
delay (5000);
int i=0;
while (i<=1){
char key = keypad.getKey();
if (key){
if( key !=NO_KEY ){
if ( 0 < amount && amount <= 5 ){
lcd.clear();
lcd.setCursor(0,0);
lcd.print( " Please wait ");
}
else{
lcd.clear();
lcd.setCursor(0,0);
lcd.print( "Enter the amount ");
int j =0;
int k =0;
while (j<=1){
char key = keypad.getKey();
if (key) {
lcd.setCursor ( k ,1);
lcd.print(key);
k ++ ;
if (k==6){
lcd.clear();
lcd.setCursor(0,0);
}
}
}
break;
}
break;
}
}
}
}
if (key!=NO_KEY){
if (key=='2'){
int allow=0;
lcd.clear();
lcd.setCursor(0,0);
lcd.print ( "Enter the amount" );
lcd.setCursor(0,1);
int b=0;
int a =0;
while (a<=1){
char key = keypad.getKey();
if (key){
lcd.setCursor ( b ,1);
lcd.print(key);
b ++ ;
if (b ==6){
lcd.clear();
lcd.print ("Transaction in Progress ");
break;
}
}
}
}
if (key!=NO_KEY){
if (key=='3'){
lcd.clear();
lcd.setCursor(0,0);
lcd.print ("Please wait") ;
delay (2000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print ("Your Account Balance is");
delay (3000);
lcd.setCursor(0,1);
lcd.print(balance);
delay(1000);
lcd.clear();
delay(2000);
break;
}
}
if (key!=NO_KEY){
if (key=='4'){
lcd.clear();
lcd.setCursor(0,0);
lcd.print ("Please wait") ;
delay ("1000");
lcd.clear();
lcd.setCursor(0,0);
lcd.print (" Transaction in Progress");
delay (1000);
break;
}
}
if (key != NO_KEY){
if (key=='5'){
lcd.clear();
lcd.setCursor(0,0);
delay (1000);
lcd.print("Take your card");
delay (2000);
break;
}
}
}
}
}
}
}
else{
lcd.print(" Incorrect pin");
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
count=0;
}
}
}
}
}
Deborah Joseph
1 project • 1 follower
Electrical and Electronics Engineering Student, University of Ibadan, Nigeria.
Comments