Annexe - programme 18b2.INO
1
2
3
OneWire ds(10); // broche 10 pour lecture des donnees
4
5
void setup() {
6
Serial.begin(9600);
7
}
8
9
void loop() {
10
byte i;
11
byte present = 0;
12
byte type_s=0;
13
byte data[12];
14
byte addr[8];
15
float celsius;
16
if ( !ds.search(addr))
17
{
18
ds.reset_search();
19
delay(250);
20
return;
21
}
22
23
Serial.print("ROM =");
24
for( i = 0; i < 8; i++)
25
{
26
Serial.write(' ');
27
Serial.print(addr[i], HEX);
28
}
29
30
ds.reset();
31
ds.select(addr);
32
ds.write(0x44, 1); // debut conversion
33
34
delay(1000);
35
36
present = ds.reset();
37
ds.select(addr);
38
ds.write(0xBE); // lecture Scratchpad
39
40
41
42
for ( i = 0; i < 9; i++)
43
{ // lecture des donnees
44
data[i] = ds.read();
45
}
46
Serial.println("");
47
Serial.print("LSB : ");
48
Serial.println(data[0],HEX);
49
Serial.print("MSB : ");
50
Serial.println(data[1],HEX);
51
}
52