Does serialEvent1() work on the Nano Every?
I'm trying to read encoder values with the same code I use on a Mega.
Works on Mega, not on Nano Every (the octal codes are for the motor
driver - MD49 from robot-electronics).
Thanks,
John-
Does serialEvent1() work on the Nano Every?
I'm trying to read encoder values with the same code I use on a Mega.
Works on Mega, not on Nano Every (the octal codes are for the motor
driver - MD49 from robot-electronics).
Thanks,
John-
What's the problem? Does it not compile? Or do you get unexpected results?
Try putting this as the last line of loop()
if (Serial1.available()) serialEvent1();
The code compiles fine; but there is not encoder values returned.
I probably should post all of the code, there's not that much.
John-
Right, so I'll try another method using Serial.Available(). I was doing that but without some added precautions:
void Encoders() {
byte Enc[8];
ReceiveEnc = true;
Serial.write(SynchByte); //Get Encoder - right then left
Serial.write(0x25);
delay(50);
EncIndex = 0;
EncWait = millis() + 20;
while (Serial1.available()) {
Enc[EncIndex] = Serial1.read();
EncIndex++;
EncWait = millis() + 20;
if(EncIndex == 8) {
encoderRt = long(Enc[0])<<24; //Get Right Encoder
encoderRt += long(Enc[1])<<16;
encoderRt += long(Enc[2])<<8;
encoderRt += long(Enc[3]);
encoderLt = long(Enc[4])<<24; //Get Left Encoder Counts
encoderLt += long(Enc[5])<<16;
encoderLt += long(Enc[6])<<8;
encoderLt += long(Enc[7]);
ReceiveEnc = false;
}
}
}
John-
Thanks, that will be the next try.
John-
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.