Assignment 1 - LED blink

Process:

I decide to use the red, yellow, green resistors (with 1.8V drop).

V = I * R
5V - 1.8V = 20mA * R
3.2V = 0.02A * R
R = 160Ω

The minimum voltage requirement is 1.8V, 3.2V > 1.8V. So it's working.
We need to find 3 resistors that close to 160Ω

What if we choose 100Ω:

3.2V = I * 100Ω
I = 0.032A
I = 32mA

The maximum current requirement is 30mA, 32mA > 30mA. So it's not working.
Therefore, I decide to use the 220Ω resistors

Code:

Start to blink from red LED
First, turn the red LED on, wait 5 s, and turn off
Second, turn both red and yellow LED on, wait 3 s, and turn off
Third, turn both yellow and green LED on, wait 1 s, and turn off
loop these steps

                
                // the setup function runs once when you press reset or power the board
                int timer = 5000; //create variable - timer is 5 second
                int delaytime = 100; //create variable - delay is 0.1 second
                void setup() {
                // use a for loop to initialize each pin as an output
                    for (int thisPin = 13; thisPin >10; thisPin--) {
                        pinMode(thisPin, OUTPUT);
                    }
                }
                
                // the loop function runs over and over again forever
                void loop() {
                // loop from ther highest to the lowest
                    for (int thisPin = 13; thisPin >10; thisPin--) {
                        digitalWrite(thisPin, HIGH);  // turn the LED on (HIGH the voltage level)
                        digitalWrite(thisPin + 1, HIGH);  // turn the LED on (HIGH the voltage level)
                        delay(timer);                 //wait for timer 5 second
                        timer = timer - 2000;         //the timer's valuable will minus 2 second
                        digitalWrite(thisPin, LOW);   // turn the LED off (LOW the voltage level)
                        digitalWrite(thisPin + 1, LOW); // turn the LED off (LOW the voltage level)
                        delay(delaytime);             //wait for delaytine which is 0.1 second
                        if (thisPin == 11) {        //if thisPin is 11
                            timer = 5000;             //set up timer to 5 second again
                        }
                    }
                }