https://os.mbed.com/users/yo2lts/code/HX711/

Dependencies:   HX711 TextLCD mbed

Fork of Nucleo_HX711_Demo by Cr300-Litho

main.cpp

Committer:
yo2lts
Date:
2018-01-29
Revision:
1:0ab2610596bf
Parent:
0:c4eaea48d411

File content as of revision 1:0ab2610596bf:

#include "mbed.h"
//#include "TextLCD.h" //Librairie Ecran text
#include "HX711.h" //Librairie HX711 en dévellopement
 
 
HX711 scale(PA_1,PA_0,128); //(pinData PA_1, pinSCK PA_0, gain [128|32|64])
//DigitalIn mybutton(USER_BUTTON);//Boutton
Serial pc(PA_2, PA_3); // tx-feher, rx-feher
DigitalOut myled(PC_13);

int main() 
{
    
    pc.printf("+++ start +++\r\n");
    myled = 0;
    wait(5);
    myled = 1;
    
    float weight;
  //  float suly;
    
    long ADCertek;
    long TAREertek;
    long float merleg;
    
    
    TAREertek = scale.getValue();   //leolvasom TARE
 //   pc.printf("TARE INITIAL Erteke = \n", TAREertek);
    while(1) 
    {
    //if (!mybutton) 
    //   scale.tare();
    
       scale.setScale(10000);
    
       scale.averageValue(10);
    
    
       ADCertek = scale.getValue();     // Leolvasom a modult    
       pc.printf("ADC Ertek = \r\n", ADCertek);
       merleg = ((long float)ADCertek-(long float)TAREertek)/11100;         // ADC ertek grama alakitasa
       pc.printf("ADCertek : %ld          Merleg : %.3lf\n",ADCertek,merleg);    // Eredmeny kiirasa
  
  
       weight = scale.getGram();

//        suly = weight/39.34;
 
//        pc.printf("------------- new\r\n");
       pc.printf("Weight gram= %.4lf\n", weight);
//        pc.printf("atalakitas weight= %.2lf\n", suly);
        wait(1);



    }
}