Created
July 22, 2024 03:11
-
-
Save hidsh/44bcc5cde4c6ab9893b343a8e26d72ea to your computer and use it in GitHub Desktop.
arduino example: calling Serial.println() from a C++ source file
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
#include "sub.h" | |
void setup(){ | |
Serial.begin(9600); | |
delay(0.5 * 1000); | |
my_log("foo"); | |
} | |
void loop(){ | |
my_log("bar"); | |
delay(1 * 1000); | |
} |
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
// sub.cpp | |
#include <Arduino.h> | |
#include "sub.h" | |
void my_log(const char *msg) { | |
Serial.println(msg); | |
} |
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
// sub.h | |
#ifdef __cplusplus | |
extern "C" { | |
#endif | |
void my_log(const char *msg); | |
#ifdef __cplusplus | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment