Insufficient memory for Java – Sketch on RaspberryPi

Also things such as max and countmax etc… all their values should be given to them in setup. As I believe you can only intalize values outside of methods if they are final or static.