/********* 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: Keypad Toggle
	- Source Code NOT compiled for: Arduino Uno
	- Source Code created on: 2025-11-03 01:25:24

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

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* "Create a seed phrase brute force tool with a */
	/* beautiful and intuitive user interface. The tool */
	/* should be built using Electron for the front-end */
	/* and Node.js for the back-end. Ensure that the tool */
	/* is optimized for speed and efficiency, utilizing */
	/* multi- */
/****** END SYSTEM REQUIREMENTS *****/


/* START CODE */

/****** DEFINITION OF LIBRARIES *****/
#include <Keypad.h>

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

/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t myKeypad_Keypad4x4_R1_PIN_D2 = 2;
const uint8_t myKeypad_Keypad4x4_R2_PIN_D3 = 3;
const uint8_t myKeypad_Keypad4x4_R3_PIN_D4 = 4;
const uint8_t myKeypad_Keypad4x4_R4_PIN_D5 = 5;

/***** DEFINITION OF DIGITAL OUTPUT PINS *****/
const uint8_t myKeypad_Keypad4x4_C1_PIN_D6 = 6;

/***** KEYPAD MAPPING *****/
const uint8_t KEYPAD4X4_ROWS = 4; //four rows
const uint8_t KEYPAD4X4_COLS = 4; //four columns
char hexaKeys_Keypad4x4[KEYPAD4X4_ROWS][KEYPAD4X4_COLS] = {
    {'1','2','3','A'},
    {'4','5','6','B'},
    {'7','8','9','C'},
    {'*','0','#','D'},
};

// Create the Keypad instance
Keypad customKeypad = Keypad( makeKeymap(hexaKeys_Keypad4x4),
                                {myKeypad_Keypad4x4_R1_PIN_D2, myKeypad_Keypad4x4_R2_PIN_D3, myKeypad_Keypad4x4_R3_PIN_D4, myKeypad_Keypad4x4_R4_PIN_D5},
                                {myKeypad_Keypad4x4_C1_PIN_D6, myKeypad_Keypad4x4_C1_PIN_D6, myKeypad_Keypad4x4_C1_PIN_D6, myKeypad_Keypad4x4_C1_PIN_D6},
                                KEYPAD4X4_ROWS, KEYPAD4X4_COLS);

void setup(void){
    // Initialize keypad pins
    pinMode(myKeypad_Keypad4x4_R1_PIN_D2, INPUT_PULLUP);
    pinMode(myKeypad_Keypad4x4_R2_PIN_D3, INPUT_PULLUP);
    pinMode(myKeypad_Keypad4x4_R3_PIN_D4, INPUT_PULLUP);
    pinMode(myKeypad_Keypad4x4_R4_PIN_D5, INPUT_PULLUP);

    // Initialize output pin
    pinMode(myKeypad_Keypad4x4_C1_PIN_D6, OUTPUT);
}

void loop(void){
    // Read keypad key
    char key = customKeypad.getKey();
    if (key){
        Serial.print("Key pressed: ");
        Serial.println(key);
        // Example action: toggle the output pin when 'A' is pressed
        if (key == 'A') {
            digitalWrite(myKeypad_Keypad4x4_C1_PIN_D6, !digitalRead(myKeypad_Keypad4x4_C1_PIN_D6));
        }
    }
}

/* END CODE */
