My Fade Assignment

This is the GIF of my working fade circuit. So admirable.

This is a picture of my circuit. I used 220 ohm resistors for the red, blue, and yellow LEDs as it was the closest standard resistor to 160 ohms I owned. For the switch, I used a 10k resistor; due to V = I * R, if the switch circuit did not have any resistance (I = V/0 = infinity), it would cause a short. Thus, I used a resistor and 10k ohms at that because it was recommended during lecture to use.

Here is a snippet of my code. I used for loops to repeatedly blink the red and blue LEDs using digitalWrite() and to fade my yellow LED using analogWrite(). Important lines of code are commented.

Here is the schematic that I drew up for my fade circuit. All calculations are presented.