Advertisement
pleasedontcode

"Motorized Sensor" rev_01

Jan 11th, 2024
73
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: "Motorized Sensor"
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-01-11 13:43:28
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* motor driver */
  21. /****** SYSTEM REQUIREMENT 2 *****/
  22.     /* motor driver */
  23. /****** END SYSTEM REQUIREMENTS *****/
  24.  
  25. /****** DEFINITION OF LIBRARIES *****/
  26. #include <Arduino.h>
  27. #include <Ultrasonic.h>
  28.  
  29. /****** SYSTEM REQUIREMENTS *****/
  30. /****** SYSTEM REQUIREMENT 1 *****/
  31.     /* motor driver */
  32. // Define any motor driver libraries or functions here
  33.  
  34. /****** SYSTEM REQUIREMENT 2 *****/
  35.     /* motor driver */
  36. // Define any motor driver libraries or functions here
  37.  
  38. /****** FUNCTION PROTOTYPES *****/
  39. void setup(void);
  40. void loop(void);
  41.  
  42. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  43. const uint8_t HC_SR04_ECHO_PIN = 3;
  44.  
  45. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  46. const uint8_t HC_SR04_TRIGGER_PIN = 2;
  47.  
  48. /****** DEFINITION OF LIBRARY CLASS INSTANCES *****/
  49. Ultrasonic ultrasonic(HC_SR04_TRIGGER_PIN, HC_SR04_ECHO_PIN);
  50.  
  51. void setup(void)
  52. {
  53.     // Motor driver setup code here
  54.  
  55.     // Ultrasonic sensor setup code here
  56.     pinMode(HC_SR04_ECHO_PIN, INPUT);
  57.     pinMode(HC_SR04_TRIGGER_PIN, OUTPUT);
  58.     Serial.begin(9600);
  59. }
  60.  
  61. void loop(void)
  62. {
  63.     // Motor driver loop code here
  64.  
  65.     // Ultrasonic sensor loop code here
  66.     Serial.print("Distance in CM: ");
  67.     Serial.println(ultrasonic.read());
  68.     delay(1000);
  69. }
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement