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.
18 This example code is in the public domain.
21 http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay
24 // constants won't change. Used here to
26 const int ledPin = 13; // the number of the LED pin
28 // Variables will change:
29 int ledState = LOW; // ledState used to set the LED
30 long previousMillis = 0; // will store last time LED was updated
32 // the follow variables is a long because the time, measured in miliseconds,
33 // will quickly become a bigger number than can be stored in an int.
34 long interval = 1000; // interval at which to blink (milliseconds)
37 // set the digital pin as output:
38 pinMode(ledPin, OUTPUT);
43 // here is where you'd put code that needs to be running all the time.
45 // check to see if it's time to blink the LED; that is, if the
46 // difference between the current time and last time you blinked
47 // the LED is bigger than the interval at which you want to
49 unsigned long currentMillis = millis();
51 if(currentMillis - previousMillis > interval) {
52 // save the last time you blinked the LED
53 previousMillis = currentMillis;
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' possibile cambiare gli intervalli dei due LED?