Hello everyone,
hope y'all doing well
I'm using two weight sensors that have the same modules in a code, and i want the first one to checks its weight first and then the second one to check its weight after that, but the thing is that they both have the the x711 module.
below is the code for the first weight sensor, now how can i add another one without interfering with the one I'm already using?
#include <hx711.h>
Hx711 scale(A1, A0);
float sensorValue ;
boolean notConnected = true;
boolean dataSent = false;
void loop() {
sensorValue = scale.getGram();
if((sensorValue >= -200) && (sensorValue <= 200) ){
lcd.setCursor(0, 0);
lcd.print(scale.getGram(), 1);
lcd.print(" g");
lcd.print(" ");
int position;
Hx711 scale(A1, A0);
This appears to create an instance of an Hx711 object named scale using analogue pins A0 and A1
If you want a completely separate instance of the same type of object using different pins then how about
Hx711 anotherScale(A3, A2);
Alqudimi:
Hello everyone,
hope y'all doing well
I'm using two weight sensors that have the same modules in a code, and i want the first one to checks its weight first and then the second one to check its weight after that, but the thing is that they both have the the x711 module.
below is the code for the first weight sensor, now how can i add another one without interfering with the one I'm already using?
#include <hx711.h>
Hx711 scale(A1, A0);
float sensorValue ;
boolean notConnected = true;
boolean dataSent = false;
void loop() {
sensorValue = scale.getGram();
if((sensorValue >= -200) && (sensorValue <= 200) ){
lcd.setCursor(0, 0);
lcd.print(scale.getGram(), 1);
lcd.print(" g");
lcd.print(" ");
int position;
you create one Hx711 instance here:
Hx711 scale(A1, A0);
have you tried creating another on two other pins?