pleasedontcode

Keypad Toggle rev_01

Nov 2nd, 2025
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: Keypad Toggle
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2025-11-03 01:25:24
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* "Create a seed phrase brute force tool with a */
  21.     /* beautiful and intuitive user interface. The tool */
  22.     /* should be built using Electron for the front-end */
  23.     /* and Node.js for the back-end. Ensure that the tool */
  24.     /* is optimized for speed and efficiency, utilizing */
  25.     /* multi- */
  26. /****** END SYSTEM REQUIREMENTS *****/
  27.  
  28.  
  29. /* START CODE */
  30.  
  31. /****** DEFINITION OF LIBRARIES *****/
  32. #include <Keypad.h>
  33.  
  34. /****** FUNCTION PROTOTYPES *****/
  35. void setup(void);
  36. void loop(void);
  37.  
  38. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  39. const uint8_t myKeypad_Keypad4x4_R1_PIN_D2 = 2;
  40. const uint8_t myKeypad_Keypad4x4_R2_PIN_D3 = 3;
  41. const uint8_t myKeypad_Keypad4x4_R3_PIN_D4 = 4;
  42. const uint8_t myKeypad_Keypad4x4_R4_PIN_D5 = 5;
  43.  
  44. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  45. const uint8_t myKeypad_Keypad4x4_C1_PIN_D6 = 6;
  46.  
  47. /***** KEYPAD MAPPING *****/
  48. const uint8_t KEYPAD4X4_ROWS = 4; //four rows
  49. const uint8_t KEYPAD4X4_COLS = 4; //four columns
  50. char hexaKeys_Keypad4x4[KEYPAD4X4_ROWS][KEYPAD4X4_COLS] = {
  51.     {'1','2','3','A'},
  52.     {'4','5','6','B'},
  53.     {'7','8','9','C'},
  54.     {'*','0','#','D'},
  55. };
  56.  
  57. // Create the Keypad instance
  58. Keypad customKeypad = Keypad( makeKeymap(hexaKeys_Keypad4x4),
  59.                                 {myKeypad_Keypad4x4_R1_PIN_D2, myKeypad_Keypad4x4_R2_PIN_D3, myKeypad_Keypad4x4_R3_PIN_D4, myKeypad_Keypad4x4_R4_PIN_D5},
  60.                                 {myKeypad_Keypad4x4_C1_PIN_D6, myKeypad_Keypad4x4_C1_PIN_D6, myKeypad_Keypad4x4_C1_PIN_D6, myKeypad_Keypad4x4_C1_PIN_D6},
  61.                                 KEYPAD4X4_ROWS, KEYPAD4X4_COLS);
  62.  
  63. void setup(void){
  64.     // Initialize keypad pins
  65.     pinMode(myKeypad_Keypad4x4_R1_PIN_D2, INPUT_PULLUP);
  66.     pinMode(myKeypad_Keypad4x4_R2_PIN_D3, INPUT_PULLUP);
  67.     pinMode(myKeypad_Keypad4x4_R3_PIN_D4, INPUT_PULLUP);
  68.     pinMode(myKeypad_Keypad4x4_R4_PIN_D5, INPUT_PULLUP);
  69.  
  70.     // Initialize output pin
  71.     pinMode(myKeypad_Keypad4x4_C1_PIN_D6, OUTPUT);
  72. }
  73.  
  74. void loop(void){
  75.     // Read keypad key
  76.     char key = customKeypad.getKey();
  77.     if (key){
  78.         Serial.print("Key pressed: ");
  79.         Serial.println(key);
  80.         // Example action: toggle the output pin when 'A' is pressed
  81.         if (key == 'A') {
  82.             digitalWrite(myKeypad_Keypad4x4_C1_PIN_D6, !digitalRead(myKeypad_Keypad4x4_C1_PIN_D6));
  83.         }
  84.     }
  85. }
  86.  
  87. /* END CODE */
  88.  
Advertisement
Add Comment
Please, Sign In to add comment