Michael Ohayon
/
HX711
Jauge de contraintes en parallèles
main.cpp@3:8baf78c3599e, 2019-01-18 (annotated)
- Committer:
- mohayonor
- Date:
- Fri Jan 18 08:51:55 2019 +0000
- Revision:
- 3:8baf78c3599e
HX711
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mohayonor | 3:8baf78c3599e | 1 | #include "mbed.h" |
mohayonor | 3:8baf78c3599e | 2 | #include "HX711.h" |
mohayonor | 3:8baf78c3599e | 3 | |
mohayonor | 3:8baf78c3599e | 4 | Serial pc(USBTX,USBRX); // Déclaration du port série USB |
mohayonor | 3:8baf78c3599e | 5 | |
mohayonor | 3:8baf78c3599e | 6 | HX711 Balance(D5,D6); // Déclaration de l'objet HX711 |
mohayonor | 3:8baf78c3599e | 7 | |
mohayonor | 3:8baf78c3599e | 8 | int main() |
mohayonor | 3:8baf78c3599e | 9 | { |
mohayonor | 3:8baf78c3599e | 10 | pc.printf("\nDebut Enregistrement\n"); |
mohayonor | 3:8baf78c3599e | 11 | |
mohayonor | 3:8baf78c3599e | 12 | long valeur; |
mohayonor | 3:8baf78c3599e | 13 | long valeurTare ; |
mohayonor | 3:8baf78c3599e | 14 | double poids; |
mohayonor | 3:8baf78c3599e | 15 | |
mohayonor | 3:8baf78c3599e | 16 | valeurTare = Balance.getValue(); // On récupère la valeur de la Tare |
mohayonor | 3:8baf78c3599e | 17 | while (true) |
mohayonor | 3:8baf78c3599e | 18 | { |
mohayonor | 3:8baf78c3599e | 19 | wait_ms(200); // Attente de 200 millisecondes |
mohayonor | 3:8baf78c3599e | 20 | valeur = Balance.getValue(); // On récupère la valeur du module |
mohayonor | 3:8baf78c3599e | 21 | poids = ((double)valeur-(double)valeurTare)/11500; // Convertionde la valeur de l'ADC en grammes |
mohayonor | 3:8baf78c3599e | 22 | pc.printf("Valeur : %ld Poids : %.3lf\n\r",valeur,poids); // Affichage du poids |
mohayonor | 3:8baf78c3599e | 23 | } |
mohayonor | 3:8baf78c3599e | 24 | |
mohayonor | 3:8baf78c3599e | 25 | pc.printf("\nFin Enregistrement\n"); |
mohayonor | 3:8baf78c3599e | 26 | } |
mohayonor | 3:8baf78c3599e | 27 |