Initial code by Liam and Samantha for motor spin.