Step 7: Build and Program the yarn dispenser's circuit
Build the circuit in the diagram below, and program it with the provided code. I determined what twelve feet of yarn was by simply timing it with a stop-watch. The code runs the motor for that amount of time (converted into milliseconds).
For convenience, I built my circuit with an H-Bridge -- an IC chip that can switch the direction of a motor. The H-Brige's direction is determined by a toggle switch. Here is a tutorial about h-bridges.