CCCPaste

"LCD Keypresses" rev_01

/********* Pleasedontcode.com **********

	Pleasedontcode thanks you for automatic code generation! Enjoy your code!

	- Terms and Conditions:
	You have a non-exclusive, revocable, worldwide, royalty-free license
	for personal and commercial use. Attribution is optional; modifications
	are allowed, but you're responsible for code maintenance. We're not
	liable for any loss or damage. For full terms,
	please visit pleasedontcode.com/termsandconditions.

	- Project: "LCD Keypresses"
	- Source Code NOT compiled for: ESP32 DevKit V1
	- Source Code created on: 2024-05-27 23:15:56

********* Pleasedontcode.com **********/

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* Create a system to interface an Arduino with an */
	/* LCD1602 display using the LiquidCrystal library. */
	/* Configure digital output pins (D4, D13, D14, D16, */
	/* D17, D18) for LCD control and ensure real-time */
	/* updates of key press data on the screen. */
/****** SYSTEM REQUIREMENT 2 *****/
	/* code will emulate a keyboard stroke and send it to */
	/* pc as keyboard click */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include 
#include 

/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);

/***** DEFINITION OF DIGITAL OUTPUT PINS *****/
const uint8_t mylcd_LCD1602_RS_PIN_D4 = 4;
const uint8_t mylcd_LCD1602_E_PIN_D13 = 13;
const uint8_t mylcd_LCD1602_D4_PIN_D14 = 14;
const uint8_t mylcd_LCD1602_D5_PIN_D16 = 16;
const uint8_t mylcd_LCD1602_D6_PIN_D17 = 17;
const uint8_t mylcd_LCD1602_D7_PIN_D18 = 18;

/***** INSTANTIATE LCD OBJECT *****/
LiquidCrystal lcd(mylcd_LCD1602_RS_PIN_D4, mylcd_LCD1602_E_PIN_D13, mylcd_LCD1602_D4_PIN_D14, mylcd_LCD1602_D5_PIN_D16, mylcd_LCD1602_D6_PIN_D17, mylcd_LCD1602_D7_PIN_D18);

void setup(void)
{
    // Initialize the LCD and set up the number of columns and rows
    lcd.begin(16, 2);
    lcd.print("Hello, World!");

    // Initialize the keyboard
    Keyboard.begin();

    // Set pin modes
    pinMode(mylcd_LCD1602_RS_PIN_D4, OUTPUT);
    pinMode(mylcd_LCD1602_E_PIN_D13, OUTPUT);
    pinMode(mylcd_LCD1602_D4_PIN_D14, OUTPUT);
    pinMode(mylcd_LCD1602_D5_PIN_D16, OUTPUT);
    pinMode(mylcd_LCD1602_D6_PIN_D17, OUTPUT);
    pinMode(mylcd_LCD1602_D7_PIN_D18, OUTPUT);
}

void loop(void)
{
    // Check for key press and update the LCD
    if (Serial.available() > 0) {
        char key = Serial.read();
        lcd.clear();
        lcd.print("Key Pressed: ");
        lcd.print(key);

        // Emulate keyboard stroke
        Keyboard.write(key);
    }
}