I have a problem right here, I cannot display measurement for load cell 2 and 3. When I run the program below. It only displays for load A and left the other 2 load B and C blanked on LCD as it didnt do the task. Please help me! Thank you in advance! What did I do wrong w the coding.
MFRC522 rfid(53, 5);
HX711 scale1(3, 2);
HX711 scale2(4, 6);
HX711 scale3(7, 8);
float loadA = 0;
float loadB = 0;
float loadC = 0;
float Base = 10.0;
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
MFRC522::MIFARE_Key key;
// Init array that will store new NUID
byte nuidPICC1[4]={0x6F,0x4D,0x32,0x28};
byte nuidPICC2[4]={0x06,0xB4,0x79,0x89};//06 B4 79 89
int pos = 0;
float calibration_factor1 = -4000;
void MoveServo1(){
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo1.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo1.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
void MoveServo2(){
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo2.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo2.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
void MoveServo3(){
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo3.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo3.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
void setup() {
Serial.begin(9600);
SPI.begin(); // Init SPI bus
rfid.PCD_Init(); // Init MFRC522
myservo1.attach(9);
myservo1.attach(10);
myservo1.attach(11);
for (byte i = 0; i < 6; i++) {
key.keyByte = 0xFF;
- }*
- scale1.set_scale();*
- scale1.tare(); //Reset the scale to 0*
- scale2.set_scale();*
- scale2.tare(); //Reset the scale to 0*
- scale3.set_scale();*
- scale3.tare(); //Reset the scale to 0*
- long zero_factor1 = scale1.read_average(); //Get a baseline reading*
- long zero_factor2 = scale2.read_average();*
- long zero_factor3 = scale3.read_average();*
- lcd.begin();*
- lcd.backlight();*
- scale1.set_scale(-184000); //Calibration Factor obtained from first sketch*
- scale1.tare();*
- scale2.set_scale(-184000); //Calibration Factor obtained from first sketch*
- scale2.tare();*
- scale3.set_scale(-184000); //Calibration Factor obtained from first sketch*
- scale3.tare();*
- lcd.clear();*
- lcd.setCursor(0,0);*
- lcd.print("Smart Waste");*
- lcd.setCursor(0,1);*
- lcd.print("Recycle Bin");*
- delay(3000);*
- lcd.clear();*
}
void loop() { - // Look for new cards*
- if ( ! rfid.PICC_IsNewCardPresent())*
- return;*
- // Verify if the NUID has been readed*
- if ( ! rfid.PICC_ReadCardSerial())*
- return;*
- MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);*
- // Check is the PICC of Classic MIFARE type*
- if (piccType != MFRC522::PICC_TYPE_MIFARE_MINI && piccType != MFRC522::PICC_TYPE_MIFARE_1K && piccType != MFRC522::PICC_TYPE_MIFARE_4K) {*
- // Serial.println(F("Your tag is not of type MIFARE Classic."));*
- return;*
- }*
- if (rfid.uid.uidByte[0] == nuidPICC1[0] || rfid.uid.uidByte[1] == nuidPICC1[1] || rfid.uid.uidByte[2] == nuidPICC1[2] || rfid.uid.uidByte[3] == nuidPICC1[3] ) {*
- lcd.clear();*
- lcd.setCursor(0,0);*
- lcd.print("User2 Acess");*
- lcd.setCursor(0,1);*
- lcd.print("Granted");*
- delay(3000);*
- lcd.clear();*
- lcd.setCursor(0,0);*
- lcd.print("Place Garbage");*
- lcd.setCursor(0,1);*
- lcd.print("on load Cell");*
- delay(3000);*
- lcd.clear();*
- lcd.setCursor(0,0);*
- lcd.print("Measuring Weight");*
- lcd.setCursor(0,1);*
- lcd.print("Please Wait");*
- delay(3000);*
- loadA= scale1.get_units(10);*
- loadB= scale2.get_units(10);*
- loadC= scale3.get_units(10);*
- lcd.clear();*
- lcd.setCursor(0,0);*
- lcd.print("Garbage Weight:");*
- lcd.setCursor(0,1);*
- lcd.print("LoadA:");*
- lcd.setCursor(7,1);*
- lcd.print(loadA);*
- lcd.setCursor(13,1);*
- lcd.print("gm");*
- lcd.setCursor(0,2);*
- lcd.print("LoadB:");*
- lcd.setCursor(7,1);*
- lcd.print(loadB);*
- lcd.setCursor(13,1);*
- lcd.print("gm");*
- lcd.setCursor(0,3);*
- lcd.print("LoadC:");*
- lcd.setCursor(7,1);*
- lcd.print(loadC);*
- lcd.setCursor(13,1);*
- lcd.print("gm");*
- } *
} *
Second problem i see, when I delete scale 1 and just register for scale2 from the part below. It still display for load A on LCD.
for (byte i = 0; i < 6; i++) {
_ key.keyByte = 0xFF;_
_ }_
scale1.set_scale();
_ scale1.tare(); //Reset the scale to 0*_
* scale2.set_scale();
_ scale2.tare(); //Reset the scale to 0*_
* scale3.set_scale();
_ scale3.tare(); //Reset the scale to 0*_
* long zero_factor1 = scale1.read_average(); //Get a baseline reading*
* long zero_factor2 = scale2.read_average();
long zero_factor3 = scale3.read_average();
I dont how as I already register loadB = scale2,
loadA= scale1.get_units(10);
loadB= scale2.get_units(10);
loadC= scale3.get_units(10);
And display at loadB on cell 2 supposedly.
I have a problem right here, I cannot display measurement for load cell 2 and 3. When I run the program below. It only displays for load A and left the other 2 load B and C blanked on LCD as it didnt do the task. Please help me! Thank you in advance!
HX711 scale1(3, 2);
HX711 scale2(4, 6);
HX711 scale3(7, 8);
float loadA = 0;
float loadB = 0;
float loadC = 0;
float Base = 10.0;
_ for (byte i = 0; i < 6; i++) {_
_ key.keyByte = 0xFF;
}_
scale1.set_scale();
_ scale1.tare(); //Reset the scale to 0*
* scale2.set_scale();*
* scale2.tare(); //Reset the scale to 0*
* scale3.set_scale();*
* scale3.tare(); //Reset the scale to 0*
* long zero_factor1 = scale1.read_average(); //Get a baseline reading*
* long zero_factor2 = scale2.read_average();
long zero_factor3 = scale3.read_average();*
* lcd.begin();
lcd.backlight();_
scale1.set_scale(-184000); //Calibration Factor obtained from first sketch*
* scale1.tare();*
* scale2.set_scale(-184000); //Calibration Factor obtained from first sketch*
* scale2.tare();*
* scale3.set_scale(-184000); //Calibration Factor obtained from first sketch*
* scale3.tare();*
* lcd.clear();*
* lcd.setCursor(0,0);*
* lcd.print("Smart Waste");*
* lcd.setCursor(0,1);*
* lcd.print("Recycle Bin");*
* delay(3000);*
* lcd.clear();*
}
\\{
* lcd.setCursor(0,0);*
* lcd.print("Place Garbage");*
* lcd.setCursor(0,1);*
* lcd.print("on load Cell");*
* delay(3000);*
* lcd.clear();*
* lcd.setCursor(0,0);*
* lcd.print("Measuring Weight");*
* lcd.setCursor(0,1);*
* lcd.print("Please Wait");*
* delay(3000);*
* loadA= scale1.get_units(10);
loadB= scale2.get_units(10);
loadC= scale3.get_units(10);
_ lcd.clear();
lcd.setCursor(0,0);
lcd.print("Garbage Weight:");
lcd.setCursor(0,1);
lcd.print("LoadA:");
lcd.setCursor(7,1);
lcd.print(loadA);
lcd.setCursor(13,1);
lcd.print("gm");
lcd.setCursor(0,2);
lcd.print("LoadB:");
lcd.setCursor(7,1);
lcd.print(loadB);
lcd.setCursor(13,1);
lcd.print("gm");
lcd.setCursor(0,3);
lcd.print("LoadC:");
lcd.setCursor(7,1);
lcd.print(loadC);
lcd.setCursor(13,1);
lcd.print("gm");
}
} *_