Ultracold atoms offer a unique platform to study spin physics. When atoms are arranged in an optical lattice in form of a Mott insulator, the atomic motion is frozen out and the study and control of the spin degree of freedom emerges as a new frontier. Heisenberg spin models, where only neighboring spins interact, are the paradigmatic model for many interesting phenomena. Until very recently, all experimental studies with cold atoms addressed the special case of an isotropic Heisenberg model. Using lithium-7 atoms and Feshbach resonances to tune the interactions, we have created spin ½ Heisenberg models with adjustable anisotropy, including the special XX-model which can be exactly solved by mapping it to non-interacting fermions. Spin transport changes from ballistic to diffusive depending on the anisotropy. For transverse spin patterns, we have found several new dephasing mechanisms related to a superexchange induced effective magnetic field. Using rubidium atoms and two atoms per site, we have realized spin 1 models. The onsite interactions give rise to a so-called-single-ion anisotropy term proportional to (S_z)^2, which plays an important role in stabilizing magnetism for low-dimensional magnetic materials. Our studies of spin dynamics illustrate the role of ultracold atoms as a quantum simulator for materials and for elucidating fundamental aspects of many-body physics.