Hello guys
I’m riding a code with several options utilizand the widget menu.
already utizo cógido with a simple menu and have no problems. but this new code some errors are appearing.
I will post the code that is giving problem and the error then.
#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <SPI.h>
#include <Ethernet.h>
#include <BlynkSimpleEthernet.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SimpleTimer.h>
#define ONE_WIRE_BUS 7
#define COOLER 4
#define LA 2
#define LB 3
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "d45054bf012e46b49f29314f95288464";
SimpleTimer timer;
void setup()
{
Serial.begin(9600);
Blynk.begin(auth);
sensors.begin();
pinMode(COOLER, OUTPUT);
digitalWrite(COOLER, LOW);
pinMode(LA, OUTPUT);
pinMode(LB, OUTPUT);
digitalWrite(LA, HIGH);
digitalWrite(LB, HIGH);
timer.setInterval(3000, readTemp);
// You can also specify server.
// For more options, see BoardsAndShields/Arduino_Ethernet_Manual example
//Blynk.begin(auth, "your_server.com", 8442);
//Blynk.begin(auth, IPAddress(192,168,1,100), 8888);
}
BLYNK_WRITE(2) //entre parenteses o número do pino virtual do menu de seleção
{
switch (param.asInt())
{
case 1: { //Seleciona o MODO AUTOMÁTICO
BLYNK_WRITE(3) //entre parenteses o número do pino virtual que vai no timer do Led Azul
{
int i = param.asInt ();
if (i == 1)
{
digitalWrite (LA, LOW);
Blynk.virtualWrite(6, 255);
}
else if (i == 0)
{
digitalWrite (LA, HIGH);
Blynk.virtualWrite(6, 0);
}
}
BLYNK_WRITE(4) //entre parenteses o número do pino virtual que vai no timer do Led Branco
{
int i = param.asInt ();
if (i == 1)
{
digitalWrite (LB, LOW);
Blynk.virtualWrite(7, 255);
}
else if (i == 0)
{
digitalWrite (LB, HIGH);
Blynk.virtualWrite(7, 0);
}
}
break;
}
case 5: {
BLYNK_WRITE(5) //entre parenteses o número do pino virtual que vai no controle independente do LED BRANCO
{
switch (param.asInt())
{
case 1: {
digitalWrite (LB, LOW);
Blynk.virtualWrite(7, 255);
break;
}
case 2: {
digitalWrite (LB, HIGH);
Blynk.virtualWrite(7, 0);
break;
}
default: { }
}
}
BLYNK_WRITE(8) //entre parenteses o número do pino virtual que vai no controle independente do LED AZUL
{
switch (param.asInt())
{
case 1: {
digitalWrite (LA, LOW);
Blynk.virtualWrite(6, 255);
break;
}
case 2: {
digitalWrite (LA, HIGH);
Blynk.virtualWrite(6, 0);
break;
}
default: { }
}
}
break;
}
default: { }
}
}
void readTemp()
{
sensors.requestTemperatures();
float floatTempC = sensors.getTempCByIndex(0);
char t_buffer[15];
dtostrf(floatTempC, 8, 9, t_buffer);
Blynk.virtualWrite(0, t_buffer);
if (floatTempC >= 27.5)
{
digitalWrite(COOLER, LOW); //LIGA COOLER
Blynk.virtualWrite(1, 255);
}
else if (floatTempC <= 27)
{
digitalWrite(COOLER, HIGH); //DESLIGA COOLER
Blynk.virtualWrite(1, 0);
}
}
void loop()
{
Blynk.run();
timer.run();
}