ze
Dependencies: mbed WakeUp OneWire
main.cpp@2:15f2d7d650bb, 2020-11-22 (annotated)
- Committer:
- mangalho_eanes
- Date:
- Sun Nov 22 20:11:11 2020 +0000
- Revision:
- 2:15f2d7d650bb
- Parent:
- 1:f4088d23f670
Commit message (required)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
BaserK | 0:fe71c302ccbb | 1 | |
BaserK | 0:fe71c302ccbb | 2 | #include "mbed.h" |
mangalho_eanes | 2:15f2d7d650bb | 3 | #include "DS1820.h" |
mangalho_eanes | 2:15f2d7d650bb | 4 | |
mangalho_eanes | 2:15f2d7d650bb | 5 | DS1820 ds1820(D9); |
mangalho_eanes | 2:15f2d7d650bb | 6 | Serial pc(USBTX,USBRX); |
mangalho_eanes | 2:15f2d7d650bb | 7 | |
mangalho_eanes | 2:15f2d7d650bb | 8 | float sonde_f = 0; |
BaserK | 0:fe71c302ccbb | 9 | |
BaserK | 0:fe71c302ccbb | 10 | int main() |
mangalho_eanes | 2:15f2d7d650bb | 11 | { |
mangalho_eanes | 2:15f2d7d650bb | 12 | |
mangalho_eanes | 2:15f2d7d650bb | 13 | //------DS18B20------// |
mangalho_eanes | 2:15f2d7d650bb | 14 | while (1){ |
mangalho_eanes | 2:15f2d7d650bb | 15 | if(ds1820.begin()) { |
mangalho_eanes | 2:15f2d7d650bb | 16 | ds1820.startConversion(); |
mangalho_eanes | 2:15f2d7d650bb | 17 | ThisThread::sleep_for(1000); |
mangalho_eanes | 2:15f2d7d650bb | 18 | sonde_f = ds1820.read(); |
mangalho_eanes | 2:15f2d7d650bb | 19 | pc.printf("%f", sonde_f); |
mangalho_eanes | 2:15f2d7d650bb | 20 | } |
mangalho_eanes | 2:15f2d7d650bb | 21 | else pc.printf("DS18B20 not found"); |
mangalho_eanes | 2:15f2d7d650bb | 22 | } |
mangalho_eanes | 2:15f2d7d650bb | 23 | /* |
mangalho_eanes | 2:15f2d7d650bb | 24 | if(ds1820.begin()) { // si bus OneWire prêt (connexion entre maître et esclave) |
mangalho_eanes | 2:15f2d7d650bb | 25 | while(1) { |
BaserK | 0:fe71c302ccbb | 26 | |
mangalho_eanes | 2:15f2d7d650bb | 27 | wait_us(10000000); |
mangalho_eanes | 2:15f2d7d650bb | 28 | ds1820.startConversion(); |
mangalho_eanes | 2:15f2d7d650bb | 29 | ThisThread::sleep_for(1000); |
mangalho_eanes | 2:15f2d7d650bb | 30 | printf("T = %4.2f\r\n", ds1820.read()); // renvoi temp dans le format "....,.." avec 0.0625 de résolution |
mangalho_eanes | 2:15f2d7d650bb | 31 | } |
mangalho_eanes | 2:15f2d7d650bb | 32 | } else |
mangalho_eanes | 2:15f2d7d650bb | 33 | pc.printf("Error DS1820 : not found.\r\n"); |
mangalho_eanes | 2:15f2d7d650bb | 34 | */ |
mangalho_eanes | 2:15f2d7d650bb | 35 | } |