1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-11-05 01:43:40 +03:00
Files
.settings
app
arduino-builder
arduino-core
build
cmd
javadoc
linux
macosx
shared
examples
01.Basics
02.Digital
03.Analog
04.Communication
05.Control
Arrays
ForLoopIteration
ForLoopIteration.ino
ForLoopIteration.txt
layout.png
schematic.png
IfStatementConditional
WhileStatementConditional
switchCase
switchCase2
06.Sensors
07.Display
08.Strings
09.USB
10.StarterKit
ArduinoISP
icons
lib
tools
Edison_help_files-1.6.2.zip.sha
Galileo_help_files-1.6.2.zip.sha
manpage.adoc
reference-1.6.0.zip.sha
revisions.txt
windows
.editorconfig
build.xml
build_all_dist.bash
build_pull_request.bash
create_reference.pl
fetch.sh
howto.txt
libastylej-2.05.zip.sha
hardware
libraries
.classpath
.gitignore
.project
README.md
format.every.sketch.sh
lib_sync
license.txt
esp8266/build/shared/examples/05.Control/ForLoopIteration/ForLoopIteration.ino
2013-10-21 09:58:40 +02:00

48 lines
1.0 KiB
C++

/*
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 30 Aug 2011
by Tom Igoe
This example code is in the public domain.
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);
}
}