Advertisement
pleasedontcode

Real-time Force Measurement rev_02

Jan 4th, 2024
113
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: Real-time Force Measurement
  13.     - Source Code compiled for: Arduino Uno
  14.     - Source Code created on: 2024-01-05 00:58:07
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* My project involves connecting one end of a sample */
  21.     /* to a load cell and the other end to the shaft, */
  22.     /* moving the motor backward to make it break. I want */
  23.     /* to see the force generated in the load cell in */
  24.     /* real time. */
  25. /****** SYSTEM REQUIREMENT 2 *****/
  26.     /* My project involves connecting one end of a sample */
  27.     /* to a load cell and the other end to the shaft, */
  28.     /* moving the motor backward to make it break. I want */
  29.     /* to see the force generated in the load cell in */
  30.     /* real time. */
  31. /****** END SYSTEM REQUIREMENTS *****/
  32.  
  33. /****** DEFINITION OF LIBRARIES *****/
  34. #include <Arduino.h>
  35. #include <HX711.h>
  36.  
  37. /****** FUNCTION PROTOTYPES *****/
  38. void setup(void);
  39. void loop(void);
  40.  
  41. /****** SYSTEM REQUIREMENTS *****/
  42. /****** SYSTEM REQUIREMENT 1 *****/
  43. /* My project involves connecting one end of a sample */
  44. /* to a load cell and the other end to the shaft, */
  45. /* moving the motor backward to make it break. I want */
  46. /* to see the force generated in the load cell in */
  47. /* real time. */
  48.  
  49. /****** SYSTEM REQUIREMENT 2 *****/
  50. /* My project involves connecting one end of a sample */
  51. /* to a load cell and the other end to the shaft, */
  52. /* moving the motor backward to make it break. I want */
  53. /* to see the force generated in the load cell in */
  54. /* real time. */
  55. /****** END SYSTEM REQUIREMENTS *****/
  56.  
  57. /***** DEFINITION OF DIGITAL INPUT PINS *****/
  58. const uint8_t dataPin = 6;
  59. const uint8_t clockPin = 7;
  60.  
  61. /****** DEFINITION OF LIBRARY CLASS INSTANCES *****/
  62. HX711 scale;
  63.  
  64. void setup(void)
  65. {
  66.   // Set the data pin as input and the clock pin as output
  67.   pinMode(dataPin, INPUT);
  68.   pinMode(clockPin, OUTPUT);
  69.  
  70.   // Initialize the HX711 object
  71.   scale.begin(dataPin, clockPin);
  72.   scale.set_scale(420.0983);
  73.   scale.tare();
  74.  
  75.   // Start the serial communication
  76.   Serial.begin(115200);
  77. }
  78.  
  79. void loop(void)
  80. {
  81.   // Read the weight from the load cell
  82.   float weight = scale.get_units(5);
  83.  
  84.   // Print the weight to the serial monitor
  85.   Serial.println(weight);
  86.  
  87.   // Delay for 250 milliseconds
  88.   delay(250);
  89. }
  90.  
  91. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement