]> git.piffa.net Git - sketchbook_andrea/blob - serial/debug_2_preprocessor_advanced/debug_2_preprocessor_advanced.ino
multitask
[sketchbook_andrea] / serial / debug_2_preprocessor_advanced / debug_2_preprocessor_advanced.ino
1 /*
2   Debug con macro per il preprocessore
3  
4  Blink v1
5  
6  Accensione e spegnimanto di un LED utilizzando variabili
7  per impostare la velocita' del lampeggio.
8  
9  Turns on an LED on for one second, then off for one second, repeatedly.
10  
11  This example code is in the public domain.
12  */
13
14 // Pin 13 has an LED connected on most Arduino boards.
15 // give it a name:
16 int led = 13;
17 int breve = 200;  // Variabile richiambile nel corso dell'esecuzione
18
19 #define DEBUG
20 // Debug
21 #ifdef DEBUG
22   #define DEBUG_PRINT(x)       Serial.print (x)
23   #define DEBUG_PRINTDEC(x)    Serial.print (x, DEC)
24   #define DEBUG_PRINTLN(x)     Serial.println (x)
25 #else 
26 /* A volte il codice di debug e' complicato e deve sostituire parte del codice
27 notmalmente usato. In questo modo potete specificare parte di codice
28 da eseguire in modalita' non-debug differente da quello di debug */
29   #define DEBUG_PRINT(x)
30   #define DEBUG_PRINTDEC(x)
31   #define DEBUG_PRINTLN(x) 
32 #endif 
33
34 // the setup routine runs once when you press reset:
35 void setup() {                
36   // initialize the digital pin as an output.
37   pinMode(led, OUTPUT);     
38   Serial.begin(9600);
39 }
40
41 // the loop routine runs over and over again forever:
42 void loop() {
43   digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
44   DEBUG_PRINTLN("Stato HIGHT");
45   delay(breve);               // wait for a second
46   digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
47   DEBUG_PRINTLN("Stato LOW");
48   delay(breve);               // wait for a second
49 }
50
51