Go Down

Topic: for loops take forever :-D (Read 376 times) previous topic - next topic

Hyperjer

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 :)
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

westfw

Are you looking for something like this?

Code: [Select]
for (byte i = 0; i<8; i++) {
 if (0 == (PIND & (1<<i))) {
    //  Bit i has dropped to zero...

 }
}

Go Up