Advertisement
pleasedontcode

Ultrasonic Setup rev_01

May 2nd, 2024
657
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: Ultrasonic Setup
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-05-02 14:32:35
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Set pin 6 as output read 1 ultrasonic sensor */
  21.     /* detect something set pin 6 to high and if it is */
  22.     /* high then set it to low then read 2nd ultrasonic */
  23.     /* sensor if someone detect set pin 6 high and if it */
  24.     /* is high then set it to low   Digital pin 6 as */
  25.     /* output */
  26. /****** END SYSTEM REQUIREMENTS *****/
  27.  
  28. /****** DEFINITION OF LIBRARIES *****/
  29. #include <Ultrasonic.h> // https://github.com/ErickSimoes/Ultrasonic
  30.  
  31. /****** FUNCTION PROTOTYPES *****/
  32. void setup(void);
  33. void loop(void);
  34. void updateOutputs(void);
  35.  
  36. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  37. const uint8_t sensor_HC_SR04_Echo_PIN_D3 = 3;
  38.  
  39. /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
  40. const uint8_t sensor_HC_SR04_Trigger_PIN_D2 = 2;
  41.  
  42. /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
  43. /***** used to store raw data *****/
  44. bool sensor_HC_SR04_Trigger_PIN_D2_rawData = 0;
  45.  
  46. /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
  47. /***** used to store data after characteristic curve transformation *****/
  48. float sensor_HC_SR04_Trigger_PIN_D2_phyData = 0.0;
  49.  
  50. /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
  51. Ultrasonic ultrasonic(sensor_HC_SR04_Trigger_PIN_D2, sensor_HC_SR04_Echo_PIN_D3);
  52.  
  53. void setup(void)
  54. {
  55.     // put your setup code here, to run once:
  56.     pinMode(sensor_HC_SR04_Echo_PIN_D3, INPUT);
  57.     pinMode(sensor_HC_SR04_Trigger_PIN_D2, OUTPUT);
  58.     pinMode(6, OUTPUT); // Set pin 6 as output for ultrasonic sensor 1
  59. }
  60.  
  61. void loop(void)
  62. {
  63.     // put your main code here, to run repeatedly:
  64.     updateOutputs(); // Refresh output data
  65. }
  66.  
  67. void updateOutputs()
  68. {
  69.     digitalWrite(sensor_HC_SR04_Trigger_PIN_D2, sensor_HC_SR04_Trigger_PIN_D2_rawData);
  70. }
  71.  
  72. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement