3 Turns on and off a light emitting diode(LED) connected to a digital
4 pin, without using the delay() function. This means that other code
5 can run at the same time without being interrupted by the LED code.
8 * LED attached from pin 13 to ground.
9 * Note: on most Arduinos, there is already an LED on the board
10 that's attached to pin 13, so no hardware is needed for this example.
19 This example code is in the public domain.
22 http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
25 // constants won't change. Used here to
27 const int ledPin = 13; // the number of the LED pin
29 // Variables will change:
30 int ledState = LOW; // ledState used to set the LED
31 long previousMillis = 0; // will store last time LED was updated
33 // the follow variables is a long because the time, measured in miliseconds,
34 // will quickly become a bigger number than can be stored in an int.
35 long interval = 1000; // interval at which to blink (milliseconds)
38 // set the digital pin as output:
39 pinMode(ledPin, OUTPUT);
44 // here is where you'd put code that needs to be running all the time.
46 // check to see if it's time to blink the LED; that is, if the
47 // difference between the current time and last time you blinked
48 // the LED is bigger than the interval at which you want to
51 if(millis() - previousMillis > interval) {
52 // save the last time you blinked the LED
53 previousMillis = millis();
55 // if the LED is off turn it on and vice-versa:
61 // set the LED with the ledState of the variable:
62 digitalWrite(ledPin, ledState);
67 1. Aggioungere un LED che brilli ogni 500ms
68 2. E' ora agevole cambiare gli intervalli dei due LED?
69 Modificare gli intervalli dei due led (es 500ms - 320ms)