> Should I changed the Arduino Mega for the Leonardo or the Due to get better performance? You didn't quite say what kind of performance gains you had in mind. Looking at your code, it doesn't have any particular needs to justify a fancier Arduino. With that said, I wanted to highlight one particular aspect of atmega32u / leonardo that in my view made it a particularly interesting chip for mixed signal application: its adc unit features a pga (1x, 10x, 200x) in differental mode with bipolar readings. it can be quite handy for some applications.