Last active
August 29, 2015 13:55
-
-
Save rlogiacco/8746231 to your computer and use it in GitHub Desktop.
Use the built in led to debug your sketch in case you don't have access to the device serial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef __LED_DEBUG | |
#define __LED_DEBUG | |
#if LED_DEBUG | |
#ifndef LED_DEBUG_PIN | |
#define LED_DEBUG_PIN LED_BUILTIN | |
#endif | |
#ifndef LED_DEBUG_DELAY | |
#define LED_DEBUG_DELAY 50 | |
#endif | |
#ifndef LED_DEBUG_LENGHT | |
#define LED_DEBUG_LENGHT 125 | |
#endif | |
#define PULSE_LNG(NUM, LENGHT) for(int __led_debug_count = 0; __led_debug_count < NUM; __led_debug_count++) {\ | |
digitalWrite(LED_DEBUG_PIN, HIGH);\ | |
delay(LENGHT);\ | |
digitalWrite(LED_DEBUG_PIN, LOW);\ | |
delay(LENGHT);\ | |
}\ | |
delay(LED_DEBUG_DELAY) | |
#define PULSE_DEF(NUM) PULSE_LNG(NUM, LED_DEBUG_LENGHT) | |
#define PULSE_ONE() digitalWrite(LED_DEBUG_PIN, HIGH);\ | |
delay(LED_DEBUG_LENGHT);\ | |
digitalWrite(LED_DEBUG_PIN, LOW);\ | |
delay(LED_DEBUG_LENGHT);\ | |
delay(LED_DEBUG_DELAY) | |
#define PULSE_X(x,NUM,LENGHT,MACRO, ...) pinMode(LED_DEBUG_PIN, OUTPUT);MACRO | |
#define PULSE(...) PULSE_X(,##__VA_ARGS__,\ | |
PULSE_LNG(__VA_ARGS__),\ | |
PULSE_DEF(__VA_ARGS__),\ | |
PULSE_ONE(__VA_ARGS__)\ | |
) | |
#else | |
#define PULSE(...) | |
#endif | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment