After I put the switch on, I got confused immediately. What I
was trying to do was actually simple. I have two sets of LEDs
and I want them to blink according to the switch. The first thing
that confused me was that, unlike what we used to think, getpin(n)=1
actually means an open circuit. And I didn't put the switch in
a complete circuit, either. So, when we put the switch on the
board, we need to make sure it has a separate circuit than the
one that goes through the chip.
So my code
is pretty simple. When the switch is on, the yellow one will blink,
otherwise the green ones will blink in turns. There are some parts
in the code that can be modified, but at least now it works fine.