Main Code

Here's the sketch. Let me know if you have any questions