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: Arduino Mega
- - Source Code created on: 2024-12-19 07:10:15
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* This Arduino project integrates three TFMPlus for */
- /* precise distance tracking by using three Serial */
- /* ports in Arduino Mega, focusing on reliable sensor */
- /* connections and data accuracy. */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <TFMPlus.h> //https://github.com/budryerson/TFMini-Plus
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
- TFMini tfmini1; // Instance for the first TFMPlus sensor
- TFMini tfmini2; // Instance for the second TFMPlus sensor
- TFMini tfmini3; // Instance for the third TFMPlus sensor
- /****** SETUP FUNCTION *****/
- void setup(void)
- {
- // Initialize the serial communication with the computer
- Serial.begin(9600); // Set bit rate of serial port connecting Arduino with computer
- // Initialize the TFMPlus sensors with the specified baud rate
- tfmini1.begin(115200);
- tfmini2.begin(115200);
- tfmini3.begin(115200);
- }
- void loop(void)
- {
- // Take one TF Mini distance measurement for each sensor
- uint16_t dist1 = tfmini1.getDistance();
- uint16_t strength1 = tfmini1.getRecentSignalStrength();
- uint16_t dist2 = tfmini2.getDistance();
- uint16_t strength2 = tfmini2.getRecentSignalStrength();
- uint16_t dist3 = tfmini3.getDistance();
- uint16_t strength3 = tfmini3.getRecentSignalStrength();
- // Display the measurement results for each sensor
- Serial.print(dist1);
- Serial.print(" cm strength: ");
- Serial.println(strength1);
- Serial.print(dist2);
- Serial.print(" cm strength: ");
- Serial.println(strength2);
- Serial.print(dist3);
- Serial.print(" cm strength: ");
- Serial.println(strength3);
- // Delay before the next measurement
- delay(1000);
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement