arduino-0018-linux-x64
This commit is contained in:
		
							parent
							
								
									8e4748e499
								
							
						
					
					
						commit
						ed785c5798
					
				
					 426 changed files with 76732 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -0,0 +1,45 @@
 | 
			
		|||
/*
 | 
			
		||||
  For Loop Iteration
 | 
			
		||||
 
 | 
			
		||||
 Demonstrates the use of a for() loop. 
 | 
			
		||||
 Lights multiple LEDs in sequence, then in reverse.
 | 
			
		||||
 
 | 
			
		||||
 The circuit:
 | 
			
		||||
 * LEDs from pins 2 through 7 to ground
 | 
			
		||||
 
 | 
			
		||||
 created 2006
 | 
			
		||||
 by David A. Mellis
 | 
			
		||||
 modified 5 Jul 2009
 | 
			
		||||
 by Tom Igoe 
 | 
			
		||||
 
 | 
			
		||||
 http://www.arduino.cc/en/Tutorial/ForLoop
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
int timer = 100;           // The higher the number, the slower the timing.
 | 
			
		||||
 | 
			
		||||
void setup() {
 | 
			
		||||
  // use a for loop to initialize each pin as an output:
 | 
			
		||||
  for (int thisPin = 2; thisPin < 8; thisPin++)  {
 | 
			
		||||
    pinMode(thisPin, OUTPUT);      
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void loop() {
 | 
			
		||||
  // loop from the lowest pin to the highest:
 | 
			
		||||
  for (int thisPin = 2; thisPin < 8; thisPin++) { 
 | 
			
		||||
    // turn the pin on:
 | 
			
		||||
    digitalWrite(thisPin, HIGH);   
 | 
			
		||||
    delay(timer);                  
 | 
			
		||||
    // turn the pin off:
 | 
			
		||||
    digitalWrite(thisPin, LOW);    
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // loop from the highest pin to the lowest:
 | 
			
		||||
  for (int thisPin = 7; thisPin >= 2; thisPin--) { 
 | 
			
		||||
    // turn the pin on:
 | 
			
		||||
    digitalWrite(thisPin, HIGH);
 | 
			
		||||
    delay(timer);
 | 
			
		||||
    // turn the pin off:
 | 
			
		||||
    digitalWrite(thisPin, LOW);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in a new issue