Boa noite pessoal, alguem pode me dar uma luz,
tenho esse programa
#include<SoftwareSerial.h>
SoftwareSerial LORA(18, 19);
SoftwareSerial nextion(22,23);
#define LEDVERMELHO 32
//#define LEDAZUL 27
#define pinobuzzer 26
void chamando();
//---------------------------------------------
boolean pisca = false; // Definido estado da variavel pisca tipo verdadeiro ou falsa
unsigned long delay1 = 0; // Definido variavel delay1 com início em 0
// constants won’t change. Used here to set a pin number:
const int ledPin = 27;// the number of the LED pin
// Variables will change:
int ledState = LOW; // ledState used to set the LED
// Generally, you should use “unsigned long” for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0; // will store last time LED was updated
// constants won’t change:
const long interval = 2000; // interval at which to blink (milliseconds)
//---------------------------------------------
//---------------------------------------------
void chamando() {
nextion.begin(9600);
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
}
if (ledState == LOW) {
nextion.print(“vis p2,1”);
nextion.print("\xFF\xFF\xFF");
nextion.print(“vis p0,0”);
nextion.print("\xFF\xFF\xFF");
//digitalWrite(pinobuzzer, HIGH);
} else {
nextion.print("vis p2,0");
nextion.print("\xFF\xFF\xFF");
nextion.print("vis p0,1");
nextion.print("\xFF\xFF\xFF");
digitalWrite(pinobuzzer, LOW);
}
}
//---------------------------------------------
void setup() {
Serial.begin(9600);
nextion.begin(9600);
LORA.begin(9600);
pinMode(LEDVERMELHO, OUTPUT);
//pinMode(LEDAZUL, OUTPUT);
pinMode(pinobuzzer, OUTPUT);
Serial.println(“Iniciando…”);
}
void loop() {
if(nextion.available()) {
int c = {nextion.read()};
Serial.println(c);
if (c == 16){
LORA.write(50);
chamando();
}
}
}
e tenho com uma funcao dentro do loop mas ela nao roda agora quando pego ela e jogo em um sketch novo ela funciona alguem sabe o por que
#include<SoftwareSerial.h>
SoftwareSerial LORA(18, 19);
SoftwareSerial nextion(22,23);
#define LEDVERMELHO 32
#define LEDAZUL 27
#define pinobuzzer 26
boolean pisca = false; // Definido estado da variavel pisca tipo verdadeiro ou falsa
unsigned long delay1 = 0; // Definido variavel delay1 com início em 0
// constants won’t change. Used here to set a pin number:
const int ledPin = 27;// the number of the LED pin
// Variables will change:
int ledState = LOW; // ledState used to set the LED
// Generally, you should use “unsigned long” for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0; // will store last time LED was updated
// constants won’t change:
const long interval = 3000; // interval at which to blink (milliseconds)
void setup() {
// set the digital pin as output:
pinMode(LEDVERMELHO, OUTPUT);
pinMode(LEDAZUL, OUTPUT);
pinMode(pinobuzzer, OUTPUT);
Serial.begin(9600);
nextion.begin(9600);
}
void loop() {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
}
if (ledState == LOW) {
nextion.print(“vis p2,0”);
nextion.print("\xFF\xFF\xFF");
nextion.print(“vis p0,1”);
nextion.print("\xFF\xFF\xFF");
//digitalWrite(pinobuzzer, HIGH);
} else {
nextion.print("vis p2,1");
nextion.print("\xFF\xFF\xFF");
nextion.print("vis p0,0");
nextion.print("\xFF\xFF\xFF");
digitalWrite(pinobuzzer, LOW);
}
}