#include <Arduino.h>
#define T0 34
#define T1 35
#define T2 36
#define LED 2
void setup()
{
pinMode(LED, OUTPUT);
pinMode(T0, INPUT);
pinMode(T1, INPUT);
pinMode(T2, INPUT);
digitalWrite(LED, HIGH);
attachInterrupt(digitalPinToInterrupt(T0), isr_T0, FALLING);
}
void loop()
{
if (digitalRead(T1) == LOW)
{
digitalWrite(LED, HIGH);
}
if (digitalRead(T2) == LOW)
{
digitalWrite(LED, LOW);
}
}
void isr_T0()
{
digitalWrite(LED, LOW);
}
You’ll find the answer here Convert Arduino file to C++ manually — PlatformIO latest documentation
Please use pre-formatted text when posting code or log files.
Also post the error log or at least describe the error you receive.
This will make it easier to help you.
1 Like
hotte
February 21, 2025, 8:54am
3
When I try to compile your code in a project, the following error message appears:
src/main.cpp: In function 'void setup()':
src/main.cpp:15:44: error: 'isr_T0' was not declared in this scope
attachInterrupt(digitalPinToInterrupt(T0), isr_T0, FALLING);
This means the declaration of the function is missing.
#include <Arduino.h>
#define T0 34
#define T1 35
#define T2 36
#define LED 2
**void isr_T0();** // <------- that was it
void setup()
{
pinMode(LED, OUTPUT);
pinMode(T0, INPUT);
pinMode(T1, INPUT);
pinMode(T2, INPUT);
digitalWrite(LED, HIGH);
attachInterrupt(digitalPinToInterrupt(T0), isr_T0, FALLING);
}
void loop()
{
if (digitalRead(T1) == LOW)
{
digitalWrite(LED, HIGH);
}
if (digitalRead(T2) == LOW)
{
digitalWrite(LED, LOW);
}
}
void isr_T0()
{
digitalWrite(LED, LOW);
}
https://learn.microsoft.com/en-us/cpp/cpp/declarations-and-definitions-cpp?view=msvc-170
I didn’t have an ESP board at hand and didn’t test the hardware requirements but if it worked in the Arduino IDE, it should work now
best regards
Holger
2 Likes
hotte
February 21, 2025, 8:57am
4
void isr_T0();
of course without the asterisks
Why the “bold” font didn’t work here, no idea!
Formatting styles cannot be applied within a pre-formatted text block as the text is already formatted.