uso un mac, ho caricato la libreria in documenti/arduino/libreria/OneWire
dal programma arduino apro la tendina "apri" carico l'esempio però mi da l'errore che ti ho indicato.
ti carico l'esempio#include <OneWire.h>
//init the one wire interface on pin 10
OneWire ds(10);
//write here the address you receive from the other program
byte sensor[8] = {0x28,0xAA,0x33,0xF0,0x02,0x00,0x00,0x79}; //SONDA "b296" DS18B20
void setup(void) {
Serial.begin(9600);
}
void writeTimeToScratchpad(byte* address){
//reset the bus
ow.reset();
//select our sensor
ow.select(address);
//CONVERT T function call (44h) which puts the temperature into thescratchpad
ow.write(0x44,1);
//sleep a second for the write to take place
delay(1000);
}
void readTimeFromScratchpad(byte* address, byte* data){
//reset the bus
ow.reset();
//select our sensor
ow.select(address);
//read the scratchpad (BEh)
ow.write(0xBE);
for (byte i=0;i<9;i++){
data = ow.read();
}
}
float getTemperature(byte* address){
int tr;
byte data[12];
writeTimeToScratchpad(address);
readTimeFromScratchpad(address,data);
//put in temp all the 8 bits of LSB (least significant byte)
tr = data[0];
//check for negative temperature
if (data[1] > 0x80){
tr = !tr + 1; //two's complement adjustment
tr = tr * -1; //flip value negative.
}
//COUNT PER Celsius degree (10h)
int cpc = data[7];
//COUNT REMAIN (0Ch)
int cr = data[6];
//drop bit 0
tr = tr >> 1;
//calculate the temperature based on this formula :
//TEMPERATURE = TEMP READ - 0.25 + (COUNT PER Celsius Degree - COUNT REMAIN) / (COUNT PER Celsius Degree)
return tr - (float)0.25 + (cpc - cr)/(float)cpc;
}
//fahrenheit to celsius conversion
float f2c(float val){
float aux = val - 32;
return (aux * 5 / 9);
}
//celsius to fahrenheit conversion
float c2f(float val){
float aux = (val * 9 / 5);
return (aux + 32);
}
void loop(void) {
float temp;
float tmp2;
tmp2 = getTemperature(sensor);
temp = c2f(tmp2);
Serial.print("Temp = ");
Serial.print(temp);
Serial.print(" F or ");
Serial.print(tmp2);
Serial.println(" C");
// Serial.flush();
//wait 1 second/s
delay(1000);
}
sketch_jul16b:3: error: 'OneWire' does not name a type
sketch_jul16b.cpp: In function 'void writeTimeToScratchpad(byte*)':
sketch_jul16b:15: error: 'ow' was not declared in this scope
sketch_jul16b.cpp: In function 'void readTimeFromScratchpad(byte*, byte*)':
sketch_jul16b:26: error: 'ow' was not declared in this scope
|
|||||||||||||||||||||||||||||||||||||||||||||||||

, come scritto e riscritto nelle regole e nei consigli iniziali che, preso dalla preoccupazione avrai omesso di leggere 