roger_marin
Published © GPL3+

44 Analog Keyboard writing on a LCD

44 Analog Keyboard writing on a LCD

IntermediateFull instructions provided280
44 Analog Keyboard writing on a LCD

Things used in this project

Hardware components

Keypad 3x4 Analog out
×1
Keypad 4x4 Analog out
×1
LCD 16x2 with serial
×1
Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Story

Read more

Code

full keyboard writing on an LCD

Arduino
I play with my daughter to write words on a screen
/* 
   simple code to test and use analog  kepads to make a full Keyboard 
    
    2021 ~ by rogermarin
    this code is in public domain
    thsi program uses the serial monitor to see tue values for each button 
    because the hrdware di  not 100% reliable on the readings I gave a + - 5 ohms of tolerance to all the mesurements 
*/


#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);

int analogPin0 = A0; // Or any pin you are using 
int analogPin1 = A1; // Or any pin you are using 
int analogPin2 = A2; // Or any pin you are using 
int val0 = 0;  // an auxiliar variable to store  the value
int val1 = 0;  // an auxiliar variable to store  the value
int val2 = 0;  // an auxiliar variable to store  the value
char key;

void setup () 
{
 Serial.begin (9600); //Setup serial to use the serial monitor 


// initialize the lcd  
lcd.init();                      
lcd.backlight();
lcd.setCursor(0,0);
}

void show (String key) //Here is where the things get print 
{
        if (key == "Clear") //Clear Screen
          {
          lcd.init();                      
          lcd.setCursor(0,0);
          }
        else if (key == "ENTER") //Cahnges Line
          {                      
          lcd.setCursor(0,1);
          }
        else
            {
            lcd.print(key);
            };
delay(500);
}
void loop () // Here we read the Keyboard 
{
     val0 = analogRead (analogPin0); //3x4 keypad 
     if (val0 >= 1020 and val0 <= 1024){show("9");};  
     if (val0 >= 925 and val0<= 935){show("0");}; 
     if (val0 >= 845 and val0<= 855){show("Clear");};
     if (val0 >= 785 and val0<= 795){show("O");};
     if (val0 >= 725 and val0 <= 735){show ("P");};
     if (val0 >= 675 and val0 <=685 ){show("!");};
     if (val0 >= 640 and val0 <= 645){show("K");};
     if (val0 >= 600 and val0 <= 610){show("L");};
     if (val0 >= 565 and val0<= 575){show("YES");};
     if (val0 >= 530 and val0 <= 550){show("M");};
     if (val0 >= 500 and val0<=515){show(" ");};
     if (val0 >= 485 and val0<=495){show("#");};

     val1 = analogRead (analogPin1); //4x4 keypad 1
     if (val1 >= 1020 and val1 <= 1024){show ("5");}; 
     if (val1 >= 925 and val1 <= 935){show("6");}; 
     if (val1 >= 845 and val1 <= 855){show("7");};
     if (val1 >= 785 and val1 <= 795){show("8");};
     if (val1 >= 675 and val1 <= 685){show("T");};
     if (val1 >= 630 and val1 <= 640){show("Y");};
     if (val1 >= 595 and val1 <= 605){show("U");};
     if (val1 >= 560 and val1 <= 570){show("I");};
     if (val1 >= 500 and val1 <= 510){show("F");}; 
     if (val1 >= 480 and val1 <= 490){show("G");};
     if (val1 >= 450 and val1 <= 460){show("H");};
     if (val1 >= 435 and val1 <= 445){show("J");};
     if (val1 >= 400 and val1 <= 410){show("C");};
     if (val1 >= 320 and val1 <= 330){show("V");};
     if (val1 >= 265 and val1 <= 275){show("B");};
     if (val1 >= 233 and val1 <= 243){show("N");};
    
      val2 = analogRead (analogPin2); //4x4 kepay 2 
     if (val2 >= 1020 and val2 <= 1024){show("1");};   
     if (val2 >= 925 and val2 <= 935){show("2");}; 
     if (val2 >= 845 and val2 <= 855){show("3");}; 
     if (val2 >= 785 and val2 <= 795){show("4");}; 
     if (val2 >= 675 and val2 <= 685){show("Q");};
     if (val2 >= 630 and val2 <= 640){show("W");}; 
     if (val2 >= 595 and val2 <= 605){show("E");}; 
     if (val2 >= 560 and val2 <= 570){show("R");}; 
     if (val2 >= 500 and val2 <= 510){show("ARDUINO");}; 
     if (val2 >= 480 and val2 <= 490){show("A");};
     if (val2 >= 450 and val2 <= 460){show("S");}; 
     if (val2 >= 435 and val2 <= 445){show("D");};
     if (val2 >= 400 and val2 <= 410){show("ENTER");};
     if (val2 >= 320 and val2 <= 330){show("DELETE");};
     if (val2 >= 265 and val2 <= 275){show("Z");};
     if (val2 >= 233 and val2 <= 243){show("X");}; 
     
}

Credits

roger_marin
6 projects • 14 followers

Comments