Advertisement
pleasedontcode

"Arduino Parking" rev_01

Dec 21st, 2023
140
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: "Arduino Parking"
  13.     - Source Code compiled for: Arduino Nano
  14.     - Source Code created on: 2023-12-21 22:00:34
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* I’m building a parking sensor. which beeps more */
  21.     /* often the closer it is to an object.   Here is the */
  22.     /* parts I’m going to use for this reciever: An */
  23.     /* Arduino nan */
  24. /****** END SYSTEM REQUIREMENTS *****/
  25.  
  26. /****** DEFINITION OF LIBRARIES *****/
  27. #include <Arduino.h>
  28. #include <Ultrasonic.h>
  29.  
  30. /****** SYSTEM REQUIREMENTS *****/
  31. /****** SYSTEM REQUIREMENT 1 *****/
  32. /* I’m building a parking sensor. which beeps more */
  33. /* often the closer it is to an object.   Here is the */
  34. /* parts I’m going to use for this reciever: An */
  35. /* Arduino nan */
  36.  
  37. /****** FUNCTION PROTOTYPES *****/
  38. void setup(void);
  39. void loop(void);
  40.  
  41. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  42. const uint8_t Sensor_HC_SR04_Echo_PIN_D3 = 3;
  43.  
  44. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  45. const uint8_t Sensor_HC_SR04_Trigger_PIN_D2 = 2;
  46.  
  47. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  48. Ultrasonic ultrasonic(Sensor_HC_SR04_Trigger_PIN_D2, Sensor_HC_SR04_Echo_PIN_D3);
  49.  
  50. void setup(void)
  51. {
  52.   // put your setup code here, to run once:
  53.   pinMode(Sensor_HC_SR04_Echo_PIN_D3, INPUT);
  54.   pinMode(Sensor_HC_SR04_Trigger_PIN_D2, OUTPUT);
  55.   Serial.begin(9600); // Initialize serial communication
  56.  
  57. }
  58.  
  59. void loop(void)
  60. {
  61.   // put your main code here, to run repeatedly:
  62.   unsigned int distance = ultrasonic.read();
  63.  
  64.   // Print the distance in centimeters
  65.   Serial.print("Distance: ");
  66.   Serial.print(distance);
  67.   Serial.println(" cm");
  68.  
  69.   delay(1000);
  70. }
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement