Advertisement
pleasedontcode

Strongbox rev_01

Sep 17th, 2023
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 4.06 KB | Software | 0 0
  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: Strongbox
  13.     - Source Code compiled for: Arduino Mega
  14.     - Source Code created on: 2023-09-17 20:10:00
  15.     - Source Code generated by: Tom
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <Wire.h>
  21. #include <LiquidCrystal_I2C.h>
  22. #include <Keypad.h>
  23. #include <Servo.h>
  24.  
  25. /****** SYSTEM REQUIREMENT 1 *****/
  26. // This is a project to create a strongbox with a keypad (to enter the code), a display (to show the state of strongbox) and a servo (to lock or unlock the door).
  27.  
  28. /****** SYSTEM REQUIREMENT 2 *****/
  29. // A code number has to be stored in EEPROM (the value is 3478) and used for comparison with the code provided by user.
  30.  
  31. /****** SYSTEM REQUIREMENT 3 *****/
  32. // At startup, Arduino has to initialize the display showing "Press digit code of 4 numbers:".
  33.  
  34. /****** SYSTEM REQUIREMENT 4 *****/
  35. // Periodically the system has to wait the code of 4 numbers from keypad. After each number is introduced, add a '*' character on the second row. When the 4 digits are introduced, check if the code is equal to the value saved in EEPROM.
  36.  
  37. /****** SYSTEM REQUIREMENT 5 *****/
  38. // Save on EEPROM also the state of machine which is composed of 2 states: "DOOR LOCKED" and "DOOR UNLOCKED".
  39.  
  40. /****** SYSTEM REQUIREMENT 6 *****/
  41. // If the code is equal to EEPROM value and the state is "DOOR LOCKED", unlock the door: drive the servo to 180 degrees, show on display 'DOOR UNLOCKED' for 2 seconds, and change the state to 'DOOR UNLOCKED'.
  42.  
  43. /****** SYSTEM REQUIREMENT 7 *****/
  44. // If the state is 'DOOR UNLOCKED', write on the display 'Enter 4 digits to lock the door', then wait for 4 digits on the keypad. And at each digit pressed, display a '*' character on the second row of the display.
  45.  
  46. /****** SYSTEM REQUIREMENT 8 *****/
  47. // After the 4 digits are entered, change the state from 'DOOR UNLOCKED' to 'DOOR LOCKED', save it in EEPROM, drive the servo to 0 degrees, display 'DOOR LOCKED' for 3 seconds, and save the code in EEPROM.
  48.  
  49. /****** FUNCTION PROTOTYPES *****/
  50. void setup(void);
  51. void loop(void);
  52.  
  53. /***** DEFINITION OF PWM OUTPUT PINS *****/
  54. const uint8_t servo_PIN_D2 = 2;
  55.  
  56. /***** DEFINITION OF I2C PINS *****/
  57. const uint8_t display_LCD1602I2C_I2C_PIN_SDA_D20 = 20;
  58. const uint8_t display_LCD1602I2C_I2C_PIN_SCL_D21 = 21;
  59. const uint8_t display_LCD1602I2C_I2C_SLAVE_ADDRESS = 39;
  60.  
  61. // Function prototypes
  62. static void initializeDisplay();
  63. static void displayMessage(const char* message);
  64. static void displayCodeEntry();
  65. static void displayCodeConfirmation();
  66. static void unlockDoor();
  67. static void lockDoor();
  68.  
  69. void setup(void)
  70. {
  71.     // Initialize the servo pin as output
  72.     pinMode(servo_PIN_D2, OUTPUT);
  73.  
  74.     // Initialize the display
  75.     initializeDisplay();
  76. }
  77.  
  78. void loop(void)
  79. {
  80.     // Main code logic goes here
  81. }
  82.  
  83. // Function to initialize the display
  84. static void initializeDisplay()
  85. {
  86.     // Code to initialize the display goes here
  87. }
  88.  
  89. // Function to display a message on the LCD
  90. static void displayMessage(const char* message)
  91. {
  92.     // Code to display the message on the LCD goes here
  93. }
  94.  
  95. // Function to display the code entry prompt on the LCD
  96. static void displayCodeEntry()
  97. {
  98.     // Code to display the code entry prompt on the LCD goes here
  99. }
  100.  
  101. // Function to display the code confirmation prompt on the LCD
  102. static void displayCodeConfirmation()
  103. {
  104.     // Code to display the code confirmation prompt on the LCD goes here
  105. }
  106.  
  107. // Function to unlock the door
  108. static void unlockDoor()
  109. {
  110.     // Code to unlock the door goes here
  111. }
  112.  
  113. // Function to lock the door
  114. static void lockDoor()
  115. {
  116.     // Code to lock the door goes here
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement