#include const int input[] = {36, 39, 34 ,35 ,32 ,33 ,25 ,26}; long inputValue[] = {0, 0, 0, 0, 0, 0, 0, 0}; const int numPins = sizeof(input) / sizeof(input[0]); Encoder enc1(14,27); Encoder enc2(13,12); long positions[3] = {0, 0, 0}; #define RXD2 (16) #define TXD2 (17) void setup() { //Serial.begin(115200); Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2); analogReadResolution(12); analogSetAttenuation(ADC_11db); } void values2uart() { for (int i = 0; i < numPins; i++) { Serial2.print(input[i]); Serial2.print("-"); Serial2.print(inputValue[i]); Serial2.print("\n"); } for (int i = 0; i < 2; i++) { Serial2.print("10"); Serial2.print(i); Serial2.print("-"); Serial2.print(positions[i]); Serial2.print("\n"); } } void loop() { for (int i = 0; i < numPins; i++) { inputValue[i] = map(analogRead(input[i]), 0, 4096, 0, 25); } long newPos1 = enc1.read(); long newPos2 = enc2.read(); if (newPos1 != positions[0]) { positions[0] = newPos1; } if (newPos2 != positions[1]) { positions[1] = newPos2; } values2uart(); delay(50); }