Pages: [1]   Go Down
Author Topic: for loops take forever :-D  (Read 314 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 62
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
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
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 106
Posts: 6378
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you looking for something like this?

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

Pages: [1]   Go Up
Jump to: