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

Dependencies:   HX711 TextLCD mbed

Fork of Nucleo_HX711_Demo by Cr300-Litho

Committer:
yo2lts
Date:
Mon Jan 29 07:31:04 2018 +0000
Revision:
1:0ab2610596bf
Parent:
0:c4eaea48d411
https://os.mbed.com/users/yo2lts/code/HX711/

Who changed what in which revision?

UserRevisionLine numberNew contents of line
BB50 0:c4eaea48d411 1 #include "mbed.h"
yo2lts 1:0ab2610596bf 2 //#include "TextLCD.h" //Librairie Ecran text
BB50 0:c4eaea48d411 3 #include "HX711.h" //Librairie HX711 en dévellopement
yo2lts 1:0ab2610596bf 4
yo2lts 1:0ab2610596bf 5
yo2lts 1:0ab2610596bf 6 HX711 scale(PA_1,PA_0,128); //(pinData PA_1, pinSCK PA_0, gain [128|32|64])
yo2lts 1:0ab2610596bf 7 //DigitalIn mybutton(USER_BUTTON);//Boutton
yo2lts 1:0ab2610596bf 8 Serial pc(PA_2, PA_3); // tx-feher, rx-feher
yo2lts 1:0ab2610596bf 9 DigitalOut myled(PC_13);
BB50 0:c4eaea48d411 10
BB50 0:c4eaea48d411 11 int main()
BB50 0:c4eaea48d411 12 {
yo2lts 1:0ab2610596bf 13
yo2lts 1:0ab2610596bf 14 pc.printf("+++ start +++\r\n");
yo2lts 1:0ab2610596bf 15 myled = 0;
yo2lts 1:0ab2610596bf 16 wait(5);
yo2lts 1:0ab2610596bf 17 myled = 1;
yo2lts 1:0ab2610596bf 18
yo2lts 1:0ab2610596bf 19 float weight;
yo2lts 1:0ab2610596bf 20 // float suly;
yo2lts 1:0ab2610596bf 21
yo2lts 1:0ab2610596bf 22 long ADCertek;
yo2lts 1:0ab2610596bf 23 long TAREertek;
yo2lts 1:0ab2610596bf 24 long float merleg;
yo2lts 1:0ab2610596bf 25
yo2lts 1:0ab2610596bf 26
yo2lts 1:0ab2610596bf 27 TAREertek = scale.getValue(); //leolvasom TARE
yo2lts 1:0ab2610596bf 28 // pc.printf("TARE INITIAL Erteke = \n", TAREertek);
BB50 0:c4eaea48d411 29 while(1)
BB50 0:c4eaea48d411 30 {
yo2lts 1:0ab2610596bf 31 //if (!mybutton)
yo2lts 1:0ab2610596bf 32 // scale.tare();
yo2lts 1:0ab2610596bf 33
yo2lts 1:0ab2610596bf 34 scale.setScale(10000);
yo2lts 1:0ab2610596bf 35
yo2lts 1:0ab2610596bf 36 scale.averageValue(10);
yo2lts 1:0ab2610596bf 37
yo2lts 1:0ab2610596bf 38
yo2lts 1:0ab2610596bf 39 ADCertek = scale.getValue(); // Leolvasom a modult
yo2lts 1:0ab2610596bf 40 pc.printf("ADC Ertek = \r\n", ADCertek);
yo2lts 1:0ab2610596bf 41 merleg = ((long float)ADCertek-(long float)TAREertek)/11100; // ADC ertek grama alakitasa
yo2lts 1:0ab2610596bf 42 pc.printf("ADCertek : %ld Merleg : %.3lf\n",ADCertek,merleg); // Eredmeny kiirasa
yo2lts 1:0ab2610596bf 43
yo2lts 1:0ab2610596bf 44
yo2lts 1:0ab2610596bf 45 weight = scale.getGram();
yo2lts 1:0ab2610596bf 46
yo2lts 1:0ab2610596bf 47 // suly = weight/39.34;
yo2lts 1:0ab2610596bf 48
yo2lts 1:0ab2610596bf 49 // pc.printf("------------- new\r\n");
yo2lts 1:0ab2610596bf 50 pc.printf("Weight gram= %.4lf\n", weight);
yo2lts 1:0ab2610596bf 51 // pc.printf("atalakitas weight= %.2lf\n", suly);
yo2lts 1:0ab2610596bf 52 wait(1);
yo2lts 1:0ab2610596bf 53
yo2lts 1:0ab2610596bf 54
yo2lts 1:0ab2610596bf 55
BB50 0:c4eaea48d411 56 }
BB50 0:c4eaea48d411 57 }