for loops take forever :-D

So i was playing around with the multiple led code found here http://www.thebox.myzen.co.uk/Workshop/LED_Sensing.html
when I realized this could be done so much better with direct port manipulation :slight_smile:
http://pastebin.com/fd778fb5

only thing that I am having trouble with is figuring out how to measure how long it takes for each led to discharge.

while ((PIND !=169)||(PINB!=43))
{
switch PIND
{
case B10101000:
break;

might end up with a huge case statement

Are you looking for something like this?

for (byte i = 0; i<8; i++) {
  if (0 == (PIND & (1<<i))) {
     //  Bit i has dropped to zero...
 
  }
}