Try putting a resistor from the input to ground, it sounds like it is picking up stray signals (rf?) and twist the input wires or shield them. I would try say 10K first. The displays=displays*10 would only be valid with 6 magnets.