4 Demonstrates the use of a for() loop.
5 Lights multiple LEDs in sequence, then in reverse.
8 * LEDs from pins 2 through 9 to ground
11 - http://lab.piffa.net/schemi/8_led_single_res_bb.png
12 - http://lab.piffa.net/schemi/8_led_single_res_schem.png
14 http://www.arduino.cc/en/Tutorial/ForLoop
17 byte ledPins[8] = { // Domanda: cosa succede se uso int?
20 int timer = 100; // Pausa per far brillare i LED
24 // use a for loop to initialize each pin as an output:
25 for (int thisPin = 0; thisPin < sizeof(ledPins); thisPin++) {
26 pinMode(ledPins[thisPin], OUTPUT);
27 Serial.print("Inizializzato pin n. ");
28 Serial.println( thisPin);
31 Serial.print("Dimesione array: ");
32 Serial.println(sizeof(ledPins));
36 // loop from the lowest pin to the highest:
37 for (int thisPin = 0; thisPin < sizeof(ledPins); thisPin++) {
38 Serial.print("Accensione pin n. ");
39 Serial.println(thisPin);
41 digitalWrite(ledPins[thisPin], HIGH);
44 digitalWrite(ledPins[thisPin], LOW);
49 // loop from the highest pin to the lowest:
50 for (int thisPin = sizeof(ledPins) -1 ; thisPin > 0; thisPin--) {
51 Serial.print("Accensione pin n. "); // Gli array sono indicizzati da 0
52 Serial.println(thisPin);
53 digitalWrite(ledPins[thisPin], HIGH);
55 digitalWrite(ledPins[thisPin], LOW);