Devices & Components
Arduino Micro
Standard LCD - 16x2 White on Blue
Rotary potentiometer (generic)
Software & Tools
Arduino IDE
Project description
Code
Password_Typer.ino
c_cpp
I think the code is pretty self explaining.
1#include <LiquidCrystal.h> 2#include <Keyboard.h> 3 4const int rs = 7, en = 8, d4 = 9, d5 = 10, d6 = 11, d7 = 12; // change to your pins of the arduino 5LiquidCrystal lcd(rs, en, d4, d5, d6, d7); // the settings for the lcd 6 7int menu; 8int PrevMenuState; 9 10int IMPORTANTJUMPER = 3; 11int button = 2; // the pin, which the button is attached on 12/* For the analog input, I couldn't use a variable, because of the A for analog, 13so you have to correct some lines 14the lines are:22,29 */ 15 16int passwords = 2; // numbers of passwords/accounts 17 18void setup() { 19 lcd.begin(16, 2); // sets the type of lcd 20 lcd.clear(); // clears the lcd 21 22 Serial.begin(9600); 23 pinMode(IMPORTANTJUMPER,INPUT_PULLUP); 24 pinMode(button,INPUT_PULLUP); 25 pinMode(A6,INPUT); 26 PrevMenuState = 2; 27 28} 29 30void loop() { 31 32 while (digitalRead(IMPORTANTJUMPER) == HIGH) { 33 // do nothing until IMPORTANTJUMPER pin goes low 34 Keyboard.end(); 35 delay(500); 36 } 37 38 menu = map(analogRead(A6),0,1024,0,passwords); // converts the 1024 steps into tinier steps 39 40 if(menu != PrevMenuState){ 41 42 lcd.clear(); 43 44 45 if(menu == 0){ 46 lcd.print("Your account which the password is for1"); 47 48 } 49 if(menu == 1){ 50 lcd.print("Your account which the password is for2"); 51 } 52/* if(menu == 2){ // for 3 accounts just undo the block comment and add 1 to the passwords int 53 Serial.println("Your account which the password is for3"); 54 }*/ 55 PrevMenuState = menu; 56 57 } 58 59 60 61 62 if(digitalRead(button) == LOW){ 63 if(menu == 0){ 64 Keyboard.print("password1"); 65 while(digitalRead(button) == LOW){} 66 } 67 if(menu == 1){ 68 Keyboard.print("password2 "); 69 while(digitalRead(button) == LOW){} 70 } 71/* if(menu == 2){ 72 Keyboard.print("password3 "); / // for 3 accounts just undo the block comment and add 1 to the passwords int 73 while(digitalRead(button) == LOW){} 74 75 }*/ 76 77 } 78 79} 80
Comments
Only logged in users can leave comments