Hello everyone, I have a nano that sends the value of the millis () function to the arudino mega via RS485 to the Serial1 port. I need this value to be stored in a global variable, but this does not happen, I hope they will help me here with a solution
this code mega
#include <Arduino.h>
#include <SPI.h>
#include <Blynk.h>
#include <Ethernet2.h>
#include <BlynkSimpleEthernet2.h>
#include <SoftwareSerial.h>
#define DIR 30
#define DIR1 31
/*
26 октября 16:20
Pins 10, 11, 12 and 13 are reserved for Ethernet module.
DON'T use them in your sketch directly!
*/
// SoftwareSerial RS485(50,51); // (RX,TX)
// ro - RX
// di - TX
BlynkTimer timer1;
BlynkTimer outputtimer ;
char auth[ ] ="auth";
int i = 0 ;
void GetData()
{
if (Serial1.available() >0 )
{
i = Serial1.read();
}
}
void OutputData(){
Serial.print("i = ");
Serial.println(i);
}
void setup()
{
Blynk.begin(auth);
// RS485.begin(9600);
Serial.begin(9600);
Serial1.begin(9600);
timer1.setInterval(5,GetData);
outputtimer.setInterval(1000,OutputData);
pinMode(DIR,OUTPUT);
digitalWrite(DIR,LOW);
pinMode(DIR1,OUTPUT);
digitalWrite(DIR,LOW);
}
void loop()
{
Blynk.run();
timer1.run();
outputtimer.run();
}