Advertisement
pleasedontcode

Smart_parking rev_01

Nov 10th, 2023
110
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: Smart_parking
  13.     - Source Code compiled for: Arduino Nano
  14.     - Source Code created on: 2023-11-11 02:21:31
  15.     - Source Code generated by: Umesh Kumar
  16.  
  17. ********* Pleasedontcode.com **********/
  18. /****** DEFINITION OF LIBRARIES *****/
  19. #include <Arduino.h>
  20. #include <Servo.h>
  21.  
  22. /****** SYSTEM REQUIREMENT 1 *****/
  23. /* No of 5 car parking in slot if one out and one add */
  24. const int MAX_PARKING_SLOTS = 5;
  25. int availableParkingSlots = MAX_PARKING_SLOTS;
  26.  
  27. /****** SYSTEM REQUIREMENT 2 *****/
  28. /* No of 5 car parking in slot if one out and one add */
  29. const int MAX_CARS_ALLOWED = 5;
  30. int currentCarsCount = 0;
  31.  
  32. /****** FUNCTION PROTOTYPES *****/
  33. void setup(void);
  34. void loop(void);
  35. void addCar();
  36. void removeCar();
  37.  
  38. /***** DEFINITION OF PWM OUTPUT PINS *****/
  39. const uint8_t Gate_open_Servomotor_PWMSignal_PIN_D3 = 3;
  40.  
  41. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  42. Servo myservo;
  43.  
  44. void setup(void)
  45. {
  46.   // put your setup code here, to run once:
  47.   pinMode(Gate_open_Servomotor_PWMSignal_PIN_D3, OUTPUT);
  48.  
  49.   // Attach the servo motor to the PWM pin
  50.   myservo.attach(Gate_open_Servomotor_PWMSignal_PIN_D3);
  51. }
  52.  
  53. void loop(void)
  54. {
  55.   // put your main code here, to run repeatedly:
  56. }
  57.  
  58. void addCar()
  59. {
  60.   if (currentCarsCount < MAX_CARS_ALLOWED && availableParkingSlots > 0)
  61.   {
  62.     currentCarsCount++;
  63.     availableParkingSlots--;
  64.     // Perform necessary actions for adding a car
  65.   }
  66. }
  67.  
  68. void removeCar()
  69. {
  70.   if (currentCarsCount > 0)
  71.   {
  72.     currentCarsCount--;
  73.     availableParkingSlots++;
  74.     // Perform necessary actions for removing a car
  75.   }
  76. }
  77.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement