ds18b20 for senior design

Dependencies:   mbed

Fork of ds18b20_test by Tuan PM

Committer:
jchari
Date:
Tue Nov 17 21:55:04 2015 +0000
Revision:
2:b369cd116bf1
Parent:
1:10bbb8a13329
So committed

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TuanPM 0:6cb99f312e0e 1 #include "mbed.h"
TuanPM 0:6cb99f312e0e 2 #include "DS1820.h"
TuanPM 0:6cb99f312e0e 3
TuanPM 0:6cb99f312e0e 4 Serial pc(SERIAL_TX, SERIAL_RX);
TuanPM 0:6cb99f312e0e 5
jchari 2:b369cd116bf1 6 const int MAX_PROBES = 1;
jchari 2:b369cd116bf1 7 DS1820 probe[1] = {A0};
TuanPM 0:6cb99f312e0e 8
TuanPM 0:6cb99f312e0e 9
TuanPM 0:6cb99f312e0e 10 int main()
TuanPM 0:6cb99f312e0e 11 {
TuanPM 1:10bbb8a13329 12 int i;
TuanPM 0:6cb99f312e0e 13 int devices_found=0;
TuanPM 0:6cb99f312e0e 14
TuanPM 0:6cb99f312e0e 15 //pc.attach(&pcRx, pc.RxIrq);
TuanPM 0:6cb99f312e0e 16 pc.printf("Started\r\n");
TuanPM 0:6cb99f312e0e 17
TuanPM 0:6cb99f312e0e 18 pc.printf("search_ROM_setup\r\n");
TuanPM 0:6cb99f312e0e 19 probe[0].search_ROM_setup();
TuanPM 0:6cb99f312e0e 20 pc.printf("search_ROM\r\n");
TuanPM 0:6cb99f312e0e 21 while (probe[devices_found].search_ROM() and devices_found<MAX_PROBES-1)
TuanPM 0:6cb99f312e0e 22 devices_found++;
TuanPM 0:6cb99f312e0e 23
TuanPM 0:6cb99f312e0e 24 // If maximum number of probes are found,
TuanPM 0:6cb99f312e0e 25 // bump the counter to include the last array entry
TuanPM 0:6cb99f312e0e 26 if (probe[devices_found].ROM[0] != 0xFF)
TuanPM 0:6cb99f312e0e 27 devices_found++;
TuanPM 0:6cb99f312e0e 28 pc.printf("devices found:%d\r\n", devices_found);
TuanPM 0:6cb99f312e0e 29
TuanPM 0:6cb99f312e0e 30
TuanPM 0:6cb99f312e0e 31 while(1) {
TuanPM 0:6cb99f312e0e 32 probe[0].convert_temperature(DS1820::all_devices);
TuanPM 0:6cb99f312e0e 33 for (i=0; i<devices_found; i++) {
jchari 2:b369cd116bf1 34 pc.printf("Device[%d]: %3.1f \r\n",i, probe[i].temperature('f'));
TuanPM 0:6cb99f312e0e 35 }
jchari 2:b369cd116bf1 36 wait(1); // 1 sec
TuanPM 0:6cb99f312e0e 37 }
TuanPM 0:6cb99f312e0e 38 }