Hi,
This is my first post, I'm relatively new to Arduino and for a project I'm working on I need to use a rotary encoder. I'm not strong at coding yet so I've been using a library I found here that uses software debouncing and code I have found for the reader and I have been editing as best I can to suit my needs. It works perfectly however I'm having trouble when I introduce the RFID reader into the mix. I have both Serial printing lines so as the encoder moves and prints a value the RFID will print an int that corresponds to each tag but I'm not sure on how separate these values to make this data usable in other applications I am using.
void reader(){
if (rfid.isCard()) {
if (rfid.readCardSerial()) {
if(rfid.serNum[0] == 66) {
int x = 1;
Serial.println(x);
}
else if(rfid.serNum[0] == 125) {
int xx = 2;
Serial.println(xx);
}
}
}
}
Here is the function I made to handle the reader data and here is the code that outputs both the reader and encoder values:
void loop() {
rotating = true; // reset the debouncer
if (lastReportedPos != encoderPos) {
rotary();
Serial.println(encoderPos, DEC);
lastReportedPos = encoderPos;
}
}
I think I may have to use sprintf but I'm not even sure how to correctly write the syntax to do so as any changes I make completely mess up the encoder values I need. Any help at all would be greatly appreciated or any advice on how to better go about doing something like this. :)