#define BLYNK_TEMPLATE_ID "TMPL4_EH-brwG"
#define BLYNK_TEMPLATE_NAME "Modetas"
#define BLYNK_AUTH_TOKEN "tLzYbKTyA86-yhP0dnXOuS4FUBqm5iun"

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <LiquidCrystal_I2C.h> 

#define BLYNK_PRINT Serial

char auth[] = "tLzYbKTyA86-yhP0dnXOuS4FUBqm5iun";
char ssid[] = "Wokwi-GUEST";
char pass[] = "";

//Variklis
const int DirPin = 19;
const int StepPin = 18;

//Jutiklis
const int Jutiklis = 17;

//Laikas
unsigned long previousMillis = 0UL;
unsigned long interval = 1000UL;

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() 
{
  
  
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);

  pinMode(Jutiklis, OUTPUT);
  pinMode(DirPin, OUTPUT);
	pinMode(StepPin, OUTPUT);

  Wire.begin(1,2);
  lcd.init();
  lcd.backlight();

  
}

void loop() 
{
  Blynk.run();
  unsigned long currentMillis = millis();
   int tempPatalpoje = TempJutiklis(Jutiklis, 7628, 923, -24, 80);

if(currentMillis - previousMillis > interval)
{

Blynk.virtualWrite(V18, tempPatalpoje);

Serial.print("Temperatura Viduje: ");
Serial.print(tempPatalpoje);
Serial.println(" ℃");
Serial.println();

lcd.setCursor(0, 0);
lcd.print("Patalpos temp: ");
lcd.print(tempPatalpoje);
lcd.print("C");

previousMillis = currentMillis;

}
  
  delay(10);
}

//Signalo pakeitimas
int TempJutiklis(int Analog, int fromLow, int fromHigh, int toLow, int toHigh)
{
  int temperatura = analogRead(Analog);
  temperatura = map(temperatura, fromLow, fromHigh, toLow, toHigh);
  return temperatura;
}

//Jungiklio programa
BLYNK_WRITE(V1) 
{
  int pinValue = param.asInt(); 
  
  if (pinValue == 1){
    digitalWrite(DirPin,HIGH);
  } else if (pinValue == 0) {
   digitalWrite(DirPin,LOW);
  }
  
  Serial.print("Mygtuko reikšmė: "); 
  Serial.println(pinValue);
}
A4988