#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);
}
uno:A5.2
uno:A4.2
uno:AREF
uno:GND.1
uno:13
uno:12
uno:11
uno:10
uno:9
uno:8
uno:7
uno:6
uno:5
uno:4
uno:3
uno:2
uno:1
uno:0
uno:IOREF
uno:RESET
uno:3.3V
uno:5V
uno:GND.2
uno:GND.3
uno:VIN
uno:A0
uno:A1
uno:A2
uno:A3
uno:A4
uno:A5
ssd1306:DATA
ssd1306:CLK
ssd1306:DC
ssd1306:RST
ssd1306:CS
ssd1306:3V3
ssd1306:VIN
ssd1306:GND
ntc1:GND
ntc1:VCC
ntc1:OUT
bz1:1
bz1:2