Basic code for magnetometer