hi to all,
i am using Gammon’s rs485 protocol for a simple project that i read an analog input from an joystick and send this value to another arduino via rs485. but there is a very interesting problem. Every time sendMsg function called, analogRead function gets interrupted. my serial monitor output is like;
179
179
179
179
179
1 -----> this is where sendMsg is called
179
179
179
179
179
179
when i comment sendMsg, code is working perfectly. Also when i uncomment the function data is sent perfectly too. i cant understand why they dont work at the same time.
void loop()
{
int t5 = analogRead(A7);
t5 = map(t5,0,1023,10,160);
if(t5<=100 && t5>= 86)
t5= 100;
if(t5>=60&&t5<=78)
t5=60;
Serial.println(t5);
motor.write(t5);
byte snd = (byte) t5;
byte msg [] = {
snd
};
sendMsg (fWrite, msg, sizeof msg);
}