Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: Distance Measurement
- - Source Code NOT compiled for: ESP32 DevKit V1
- - Source Code created on: 2024-10-22 07:26:42
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* design a circuit for pothole detection system */
- /* using ESP32-CAM,ultrasonic sensor, GPRS, FT232RL */
- /* FTDI USB to TTL Serial Converter 40Pin Jumper */
- /****** END SYSTEM REQUIREMENTS *****/
- /****** DEFINITION OF LIBRARIES *****/
- #include <Ultrasonic.h> // https://github.com/ErickSimoes/Ultrasonic
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /***** DEFINITION OF DIGITAL INPUT PINS *****/
- const uint8_t HC_SR04_ultrasonice_HC-SR04_Echo_PIN_D13 = 13; // Echo pin for the ultrasonic sensor
- const uint8_t HC_SR04_ultrasonice_HC-SR04_Trig_PIN_D12 = 12; // Trigger pin for the ultrasonic sensor
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES *****/
- // Instantiate the Ultrasonic object with the trigger and echo pins
- Ultrasonic ultrasonic(HC_SR04_ultrasonice_HC-SR04_Trig_PIN_D12, HC_SR04_ultrasonice_HC-SR04_Echo_PIN_D13);
- void setup(void)
- {
- // Initialize serial communication for debugging
- Serial.begin(9600);
- // Set the echo pin as input
- pinMode(HC_SR04_ultrasonice_HC-SR04_Echo_PIN_D13, INPUT);
- // Set a timeout for the ultrasonic sensor
- ultrasonic.setTimeout(40000UL); // Set timeout to 40ms
- }
- void loop(void)
- {
- // Read the distance from the ultrasonic sensor
- Serial.print("Distance in CM: ");
- Serial.println(ultrasonic.read()); // Print the distance in centimeters
- delay(1000); // Wait for 1 second before the next reading
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement