/*Keypad example
by miliohm.com */
#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
#include <Stepper.h>
int stepsPerRevolution = 200;
// change this to fit the number of steps per revolution
// for your motor
// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 10, 11,12,13);
String pad;
const byte numRows = 4;
const byte numCols = 4;
String password = "4321";
String msgA="A:Odaberi kut";
String msgB="B:Koliko rupa";
String msg1="Kut je:";
int Zadanikut;
String Ali="A";
float kut;
char keypressed;
char mykey;
char keymap[numRows][numCols] =
{
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
//------------------------------------------------------------
byte rowPins[numRows] = { 9, 8, 7, 6 };
byte colPins[numCols] = { 5, 4, 3, 2 };
Keypad myKeypad = Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols); //mapping keypad
void setup() {
myStepper.setSpeed(60);
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print(msgA);
lcd.setCursor(0, 1);
lcd.print(msgB);
delay(1000);
}
void loop() {
// put your main code here, to run repeatedly:
readKeypad();
if (keypressed == 'A'){
lcd.clear();
lcd.print(msg1);
Zadanikut=lcd.print(pad);
kut=(200./360.)*Zadanikut;
myStepper.step(kut);
delay(500);
}
if (keypressed == '#') {
if (pad == password) {
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("Access Granted");
} else {
lcd.setCursor(0, 1);
lcd.clear();
lcd.print("Access Denied");
}
} if (keypressed == '*') {
pad = "";
lcd.clear();
}
lcd.setCursor(0, 1);
lcd.print(pad);
delay(10);
}
void readKeypad() {
keypressed = myKeypad.getKey(); //deteksi penekanan keypad
if (keypressed != '#' && keypressed != 'A') {
String konv = String(keypressed);
pad += konv;
}
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
keypad1:R1
keypad1:R2
keypad1:R3
keypad1:R4
keypad1:C1
keypad1:C2
keypad1:C3
keypad1:C4
stepper1:A-
stepper1:A+
stepper1:B+
stepper1:B-
lcd1:GND
lcd1:VCC
lcd1:SDA
lcd1:SCL