Team DIANA
/
ScientificGara
pseudo-code scientific gara
main.cpp@0:9e66b8d2ee5a, 2019-09-11 (annotated)
- Committer:
- Alessio_Zaino
- Date:
- Wed Sep 11 10:26:24 2019 +0000
- Revision:
- 0:9e66b8d2ee5a
scientific gara
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Alessio_Zaino | 0:9e66b8d2ee5a | 1 | #include "mbed.h" |
Alessio_Zaino | 0:9e66b8d2ee5a | 2 | #include "HX711.h" |
Alessio_Zaino | 0:9e66b8d2ee5a | 3 | PwmOut servo1(D3); |
Alessio_Zaino | 0:9e66b8d2ee5a | 4 | PwmOut servo2(D5); |
Alessio_Zaino | 0:9e66b8d2ee5a | 5 | PwmOut servo3(D6); |
Alessio_Zaino | 0:9e66b8d2ee5a | 6 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 7 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 8 | HX711 Balance1(D7,D13); // Declaration |
Alessio_Zaino | 0:9e66b8d2ee5a | 9 | HX711 Balance2(D8,D13); // Declaration |
Alessio_Zaino | 0:9e66b8d2ee5a | 10 | HX711 Balance3(D9,D13); // Declaration |
Alessio_Zaino | 0:9e66b8d2ee5a | 11 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 12 | int main() |
Alessio_Zaino | 0:9e66b8d2ee5a | 13 | { |
Alessio_Zaino | 0:9e66b8d2ee5a | 14 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 15 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 16 | long value1,value2,value3; |
Alessio_Zaino | 0:9e66b8d2ee5a | 17 | float weight,weight2,weight3; |
Alessio_Zaino | 0:9e66b8d2ee5a | 18 | servo1.period(0.02f); |
Alessio_Zaino | 0:9e66b8d2ee5a | 19 | servo2.period(0.02f); |
Alessio_Zaino | 0:9e66b8d2ee5a | 20 | servo3.period(0.02f); |
Alessio_Zaino | 0:9e66b8d2ee5a | 21 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 22 | while (true) |
Alessio_Zaino | 0:9e66b8d2ee5a | 23 | { |
Alessio_Zaino | 0:9e66b8d2ee5a | 24 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 25 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 26 | if(SEGNALE PER SCATOLA1){ |
Alessio_Zaino | 0:9e66b8d2ee5a | 27 | servo1.pulsewidth(2200/1000000.0);//chiude box 1 |
Alessio_Zaino | 0:9e66b8d2ee5a | 28 | value1 = Balance1.averageValue(100); |
Alessio_Zaino | 0:9e66b8d2ee5a | 29 | weight = (value1-11669475)/2450.0; // I had to use the 788 value after testing with weight |
Alessio_Zaino | 0:9e66b8d2ee5a | 30 | //INVIARE WEIGHT |
Alessio_Zaino | 0:9e66b8d2ee5a | 31 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 32 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 33 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 34 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 35 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 36 | } |
Alessio_Zaino | 0:9e66b8d2ee5a | 37 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 38 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 39 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 40 | if(SEGNALE SCATOLA2){ |
Alessio_Zaino | 0:9e66b8d2ee5a | 41 | servo2.pulsewidth(2100/1000000.0);//chiude box 2 |
Alessio_Zaino | 0:9e66b8d2ee5a | 42 | value2 = Balance2.averageValue(100); |
Alessio_Zaino | 0:9e66b8d2ee5a | 43 | weight2 = (value2-8506861)/940.0; |
Alessio_Zaino | 0:9e66b8d2ee5a | 44 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 45 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 46 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 47 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 48 | } |
Alessio_Zaino | 0:9e66b8d2ee5a | 49 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 50 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 51 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 52 | if(SEGNALRE SCATOLA3){ |
Alessio_Zaino | 0:9e66b8d2ee5a | 53 | servo3.pulsewidth(2200/1000000.0);//chiude box 3 |
Alessio_Zaino | 0:9e66b8d2ee5a | 54 | value3 = Balance3.averageValue(100); |
Alessio_Zaino | 0:9e66b8d2ee5a | 55 | weight3 = (value3-9923525)/1800.0; |
Alessio_Zaino | 0:9e66b8d2ee5a | 56 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 57 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 58 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 59 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 60 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 61 | } |
Alessio_Zaino | 0:9e66b8d2ee5a | 62 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 63 | } |
Alessio_Zaino | 0:9e66b8d2ee5a | 64 | |
Alessio_Zaino | 0:9e66b8d2ee5a | 65 | } |
Alessio_Zaino | 0:9e66b8d2ee5a | 66 |