├── .gitattributes ├── README.md ├── DebugUtils └── DebugUtils.h └── Examples ├── Debug_Serial └── Debug_Serial.ino ├── Debug_with_Statements └── Debug_with_Statements.ino └── With_Neopixels └── With_Neopixels.ino /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Pre-Compiler-Directives 2 | 3 | Examples and "Libary File" DebugUtils which has to be copied (including its directory) into your Arduino Library folder 4 | 5 | YouTube video with explanations: https://youtu.be/1eL8dXL3Wow 6 | 7 | -------------------------------------------------------------------------------- /DebugUtils/DebugUtils.h: -------------------------------------------------------------------------------- 1 | // Debug utilities 2 | 3 | #if DEBUGLEVEL >= 0 4 | #define DEBUGPRINT0(x) Serial.print(x) 5 | #define DEBUGPRINTLN0(x) Serial.println(x) 6 | #define DEBUGSERIALBEGIN(x) Serial.begin(x) 7 | #else 8 | #define DEBUGPRINT0(x) 9 | #define DEBUGPRINTLN0(x) 10 | #define DEBUGSERIALBEGIN(x) 11 | #endif 12 | 13 | #if DEBUGLEVEL >= 1 14 | #define DEBUGPRINT1(x) Serial.print(x) 15 | #define DEBUGPRINTLN1(x) Serial.println(x) 16 | #else 17 | #define DEBUGPRINT1(x) 18 | #define DEBUGPRINTLN1(x) 19 | #endif 20 | 21 | #if DEBUGLEVEL >= 2 22 | #define DEBUGPRINT2(x) Serial.print(x) 23 | #define DEBUGPRINTLN2(x) Serial.println(x) 24 | #else 25 | #define DEBUGPRINT2(x) 26 | #define DEBUGPRINTLN2(x) 27 | #endif 28 | 29 | #if DEBUGLEVEL >= 3 30 | #define DEBUGPRINT3(x) Serial.print(x) 31 | #define DEBUGPRINTLN3(x) Serial.println(x) 32 | #else 33 | #define DEBUGPRINT3(x) 34 | #define DEBUGPRINTLN3(x) 35 | #endif -------------------------------------------------------------------------------- /Examples/Debug_Serial/Debug_Serial.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Blink 3 | 4 | Turns an LED on for one second, then off for one second, repeatedly. 5 | 6 | Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO 7 | it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to 8 | the correct LED pin independent of which board is used. 9 | If you want to know what pin the on-board LED is connected to on your Arduino 10 | model, check the Technical Specs of your board at: 11 | https://www.arduino.cc/en/Main/Products 12 | 13 | modified 8 May 2014 14 | by Scott Fitzgerald 15 | modified 2 Sep 2016 16 | by Arturo Guadalupi 17 | modified 8 Sep 2016 18 | by Colby Newman 19 | 20 | This example code is in the public domain. 21 | 22 | http://www.arduino.cc/en/Tutorial/Blink 23 | */ 24 | 25 | #define DEBUGLEVEL 3 26 | 27 | 28 | #include 29 | 30 | #define D1 5 31 | 32 | 33 | #define LED D1 34 | 35 | // the setup function runs once when you press reset or power the board 36 | void setup() { 37 | Serial.begin(115200); 38 | // initialize digital pin LED as an output. 39 | pinMode(LED, OUTPUT); 40 | 41 | Serial.println("Started"); 42 | } 43 | 44 | // the loop function runs over and over again forever 45 | void loop() { 46 | Serial.println("Loop started"); 47 | 48 | digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level) 49 | Serial.print("Point 1 "); 50 | Serial.println(digitalRead(LED)); 51 | 52 | delay(1000); // wait for a second 53 | digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW 54 | Serial.print("Point 2 "); 55 | Serial.println(digitalRead(LED)); 56 | 57 | delay(1000); // wait for a second 58 | } 59 | -------------------------------------------------------------------------------- /Examples/Debug_with_Statements/Debug_with_Statements.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Blink 3 | 4 | Turns an LED on for one second, then off for one second, repeatedly. 5 | 6 | Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO 7 | it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to 8 | the correct LED pin independent of which board is used. 9 | If you want to know what pin the on-board LED is connected to on your Arduino 10 | model, check the Technical Specs of your board at: 11 | https://www.arduino.cc/en/Main/Products 12 | 13 | modified 8 May 2014 14 | by Scott Fitzgerald 15 | modified 2 Sep 2016 16 | by Arturo Guadalupi 17 | modified 8 Sep 2016 18 | by Colby Newman 19 | 20 | This example code is in the public domain. 21 | 22 | http://www.arduino.cc/en/Tutorial/Blink 23 | */ 24 | 25 | #define DEBUGLEVEL 0 26 | #include 27 | 28 | 29 | #define D1 5 30 | 31 | 32 | #define LED D1 33 | 34 | // the setup function runs once when you press reset or power the board 35 | void setup() { 36 | Serial.begin(115200); 37 | // initialize digital pin LED as an output. 38 | pinMode(LED, OUTPUT); 39 | 40 | DEBUGPRINTLN0("Started"); 41 | } 42 | 43 | // the loop function runs over and over again forever 44 | void loop() { 45 | DEBUGPRINTLN0("Loop started"); 46 | 47 | digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level) 48 | DEBUGPRINT1("Point 1 "); 49 | DEBUGPRINTLN1(digitalRead(LED)); 50 | 51 | delay(1000); // wait for a second 52 | digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW 53 | DEBUGPRINT2("Point 2 "); 54 | DEBUGPRINTLN2(digitalRead(LED)); 55 | 56 | delay(1000); // wait for a second 57 | } 58 | -------------------------------------------------------------------------------- /Examples/With_Neopixels/With_Neopixels.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Blink 3 | 4 | Turns an LED on for one second, then off for one second, repeatedly. 5 | 6 | Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO 7 | it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to 8 | the correct LED pin independent of which board is used. 9 | If you want to know what pin the on-board LED is connected to on your Arduino 10 | model, check the Technical Specs of your board at: 11 | https://www.arduino.cc/en/Main/Products 12 | 13 | modified 8 May 2014 14 | by Scott Fitzgerald 15 | modified 2 Sep 2016 16 | by Arturo Guadalupi 17 | modified 8 Sep 2016 18 | by Colby Newman 19 | 20 | This example code is in the public domain. 21 | 22 | http://www.arduino.cc/en/Tutorial/Blink 23 | */ 24 | 25 | #define DEBUGLEVEL 0 26 | 27 | #define WITHNEOPIXELS 28 | 29 | #include 30 | 31 | #if defined ESP8266 32 | #include 33 | #else 34 | #include 35 | #define D1 5 36 | #endif 37 | 38 | #ifdef WITHNEOPIXELS 39 | #include 40 | Adafruit_NeoPixel strip = Adafruit_NeoPixel(8, D1, NEO_GRB + NEO_KHZ800); 41 | #endif 42 | 43 | 44 | // #define LED D1 45 | int LED = D1; 46 | 47 | // the setup function runs once when you press reset or power the board 48 | void setup() { 49 | Serial.begin(115200); 50 | 51 | #ifdef WITHNEOPIXELS 52 | strip.begin(); 53 | for (int i = 0; i < 8; i++) strip.setPixelColor(i, 0, 0, 0); 54 | strip.show(); // Initialize all pixels to 'off' 55 | #else 56 | // initialize digital pin LED as an output. 57 | pinMode(LED, OUTPUT); 58 | #endif 59 | 60 | DEBUGPRINTLN0("Started"); 61 | } 62 | 63 | // the loop function runs over and over again forever 64 | void loop() { 65 | DEBUGPRINT0("Loop started"); 66 | DEBUGPRINT1("Point 1 "); 67 | #ifdef WITHNEOPIXELS 68 | strip.setPixelColor(5, 127, 0, 0); 69 | strip.show(); 70 | #else 71 | digitalWrite(LED, HIGH); // turn the LED on (HIGH is the voltage level) 72 | DEBUGPRINTLN1(digitalRead(LED)); 73 | #endif 74 | 75 | 76 | 77 | delay(1000); // wait for a second 78 | #ifdef WITHNEOPIXELS 79 | strip.setPixelColor(5, 0, 127, 0); 80 | strip.show(); 81 | #else 82 | digitalWrite(LED, LOW); // turn the LED off by making the voltage LOW 83 | DEBUGPRINTLN2(digitalRead(LED)); 84 | #endif 85 | DEBUGPRINT2("Point 2 "); 86 | 87 | delay(1000); // wait for a second 88 | } 89 | --------------------------------------------------------------------------------