/********* 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: Real-time Force Measurement
- Source Code compiled for: Arduino Uno
- Source Code created on: 2024-01-05 00:58:07
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* My project involves connecting one end of a sample */
/* to a load cell and the other end to the shaft, */
/* moving the motor backward to make it break. I want */
/* to see the force generated in the load cell in */
/* real time. */
/****** SYSTEM REQUIREMENT 2 *****/
/* My project involves connecting one end of a sample */
/* to a load cell and the other end to the shaft, */
/* moving the motor backward to make it break. I want */
/* to see the force generated in the load cell in */
/* real time. */
/****** END SYSTEM REQUIREMENTS *****/
/****** DEFINITION OF LIBRARIES *****/
#include
#include
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* My project involves connecting one end of a sample */
/* to a load cell and the other end to the shaft, */
/* moving the motor backward to make it break. I want */
/* to see the force generated in the load cell in */
/* real time. */
/****** SYSTEM REQUIREMENT 2 *****/
/* My project involves connecting one end of a sample */
/* to a load cell and the other end to the shaft, */
/* moving the motor backward to make it break. I want */
/* to see the force generated in the load cell in */
/* real time. */
/****** END SYSTEM REQUIREMENTS *****/
/***** DEFINITION OF DIGITAL INPUT PINS *****/
const uint8_t dataPin = 6;
const uint8_t clockPin = 7;
/****** DEFINITION OF LIBRARY CLASS INSTANCES *****/
HX711 scale;
void setup(void)
{
// Set the data pin as input and the clock pin as output
pinMode(dataPin, INPUT);
pinMode(clockPin, OUTPUT);
// Initialize the HX711 object
scale.begin(dataPin, clockPin);
scale.set_scale(420.0983);
scale.tare();
// Start the serial communication
Serial.begin(115200);
}
void loop(void)
{
// Read the weight from the load cell
float weight = scale.get_units(5);
// Print the weight to the serial monitor
Serial.println(weight);
// Delay for 250 milliseconds
delay(250);
}
/* END CODE */