Adding an external .c file to an .ino project

When creating a sketch in Arduino IDE (1.8.19) I'm getting a skeleton with setup() and loop().
I assume, when I want to include a .h file, I simply put it into the directory where the .ino file is located. But assumed I have some driver code in a extra external .c file, where do I put this file and how do I make the arduino IDE becoming aware of it so that it is included (linked) to my main program?

Put everything in the same folder.
If the .h files and the .c files have the same name the compiler/linker will find them.

try renaming it to ino file and put it in current folder

Thanks. Renaming the .C file to .ino seems to work.

Putting just the files there and leaving them named .C doesn't link the .C file.

Often it's a matter of renaming .c to .cpp

If you want to add C language source files to your sketch, make sure to use the .c file extension (not .C with an uppercase "C"). C language files are supported, but in most cases I think it is easiest to use .ino, or .cpp if you really don't want the Arduino sketch preprocessing done on the code.

Thanks for pointing that out. Actually writing .C (upper case) was only a lazyness on my side. I did not really mean to write it upper case. But good to know.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.