#include "U8glib.h"
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_DEV_0 | U8G_I2C_OPT_NO_ACK | U8G_I2C_OPT_FAST); // Fast I2C / TWI
int valorTemp = 0;
const float BETA = 3950;
char buffer[20];
#define Campainha 8;
unsigned long startMillis; //some global variables available anywhere in the program
unsigned long currentMillis;
void setup() {
u8g.setFont(u8g_font_tpssb);
u8g.setColorIndex(1);
pinMode(8, OUTPUT);
startMillis = millis();
}
void loop() {
u8g.firstPage();
currentMillis = millis();
if (analogRead(A0) <= 500) {
if (currentMillis - startMillis <= 200) tone(8, 1000, 250);
if (currentMillis - startMillis > 200) noTone(8);
if (currentMillis - startMillis > 400) startMillis = currentMillis;
}
else {
noTone(8);
}
//Serial.begin(9600);
// Serial.println(analogRead(A0));
do {
dtostrf(1 / (log(1 / (1023. / valorTemp - 1)) / BETA + 1.0 / 298.15) - 273.15, 1, 1, buffer);
sprintf(buffer, "%s%s", buffer, " Celsius");
u8g.drawStr(25, 50, buffer);
u8g.drawFrame(0, 10, 128, 20);
u8g.drawBox(10, 15, map(valorTemp, 953, 115, 0, 108), 10);
} while ( u8g.nextPage() );
valorTemp = analogRead(A0);
}