sensore temperatura ds18b20 e 7 segment display sparkfun

Ciao Paolo, scusa ma non ho avuto piu avuto il tempo di fare le prove... :wink:

posto lo sketch completo... per provare con il segno meno ho impostare im modo che superando i 25 gradi viene aggiunto il segno -
Funziona...solo che quando la temperatura ritorna al di sotto dei 25 gradi mantiene il segno meno... come si potrebbe fare? bisognerebbe resettare il display al cambio di segno?

ho provato...dato che per fare il segno meno ho usato Wire.write(0x7B); Wire.write(0b01000000);

ho pensato che magari inviando Wire.write(0x7B); Wire.write(0b00000000); non accendesse nessun led ma invece non funziona

/*
11-2-2012
Spark Fun Electronics
Nathan Seidle
This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).

Serial7Segment is an open source seven segment display.

This is example code that shows how to send data over I2C to the display.
Note: This code expects the display to be listening at the default I2C address. If your display is not at 0x71, you can
do a software or hardware reset. See the Wiki for more info:
http://github.com/sparkfun/Serial7SegmentDisplay/wiki/Special-Commands
To get this code to work, attached an Serial7Segment to an Arduino Uno using the following pins:
A5 to SCL
A4 to SDA
VIN to PWR
GND to GND

*/

#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define DISPLAY_ADDRESS1 0x71 //This is the default address of the OpenSegment with both solder jumpers open
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);


void setup()
{
  Wire.begin(); //Join the bus as master
  sensors.begin();
  Serial.begin(9600); //Start serial communication at 9600 for debug statements

  //Send the reset command to the display - this forces the cursor to return to the beginning of the display
  Wire.beginTransmission(DISPLAY_ADDRESS1);
  Wire.write('v');
  Wire.endTransmission();
}

void loop(void)
{
  sensors.requestTemperatures();
  Serial.print("Temperatura ");
  Serial.print(sensors.getTempCByIndex(0));
  Serial.println(" C");
 int temperature = (int) (sensors.getTempCByIndex(0)*10);
 i2cSendValue(temperature); //Send the four characters to the display
delay(1000);
}


void i2cSendValue(int temp)
{
  Wire.beginTransmission(DISPLAY_ADDRESS1); // transmit to device #1
  if (temp>250)
  {
   Wire.write(0x7B); // Seleziona la prima cifra   
   Wire.write(0b01000000); // invia il carattere -
  
   }
 if (temp/1000>0) 
    { 
     Wire.write(temp / 1000); //Send the left most digit
    }
  else
    { 
     Wire.write(0x79);
     Wire.write(0x01);
    }
  temp %= 1000; //Now remove the left most digit from the number we want to display
 if (temp/100>0) 
    { 
     Wire.write(temp / 100);
    }
  else
    { 
     Wire.write(0x79);
     Wire.write(0x02);
    }  
  temp %= 100;
  Wire.write(temp / 10);
  temp %= 10;
  Wire.write(temp); //Send the right most digit
  Wire.write(0x77); // invia il punto decimale
  Wire.write(4);
  Wire.endTransmission(); //Stop I2C transmission
}