]> git.piffa.net Git - sketchbook_andrea/blobdiff - programming/loops/loop_1_array_loop/loop_1_array_loop.ino
loops array
[sketchbook_andrea] / programming / loops / loop_1_array_loop / loop_1_array_loop.ino
index 42871ef279b1c2192f11272cb45d3e393fc105f2..bb9662ecd1b1eaa0a60348ee77bbf2c5b064681d 100644 (file)
@@ -1,12 +1,8 @@
 /* Knight Rider 2
  * --------------
+ * 
+ * Array e uso dei cicli iterativi.
  *
- * Reducing the amount of code using for(;;).
- *
- *
- * (cleft) 2005 K3, Malmo University
- * @author: David Cuartielles
- * @hardware: David Cuartielles, Aaron Hallborg
 
 
    Schema semplificato: 
  */
 
 int pinArray[8] = {2, 3, 4, 5, 6, 7, 8, 9};
-int count = 0;
 int timer = 100;
 
 void setup(){
   // we make all the declarations at once
-  for (count=0;count<9;count++) {
+  for (int count=0;count<9;count++) {
     pinMode(pinArray[count], OUTPUT);
   }
 }
 
 void loop() {
-  for (count=0;count<8;count++) { // 8 e' un numero magico
+  for (int count=0;count<8;count++) { // 8 e' un numero magico
    digitalWrite(pinArray[count], HIGH);
    delay(timer);
    digitalWrite(pinArray[count], LOW);
    delay(timer);
   }
-  for (count=8;count>=0;count--) {
+
+// Ciclo inverso: dall'alto in basso  
+  for (int count=8;count>=0;count--) {
    digitalWrite(pinArray[count], HIGH);
    delay(timer);
    digitalWrite(pinArray[count], LOW);
@@ -46,6 +43,16 @@ void loop() {
  2. Come posso fare per uscire completamente dal loop? 
  3. 8 e' un numero magico: come posso evitarlo?
 
+.
+.
+.
+.
+.
+.
+.
+.
+.
+.
 .
 .
 .