Spin dynamics in lattices of spinor atoms with quadratic Zeeman effect