Go Down

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


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

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:

might end up with a huge case statement


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