I'd start to use arduino

Hi, I’m a newbie and I’d start to use arduino, I’ve already know C, can I use arduino with the C language?
Because I not want learn another language.

Yes.

I’ve tried to search on google, but I’ve found a few tutorial on “how to use C on arduino”, anyone
have a tutorial on how to use C on arduino?

The important thing to understand is that the .ino files of Arduino sketches are compiled as C++ after some minimal preprocessing. C++ is, for the most part, a superset of C, so you can use C in the .ino files.

If you want your code to be compiled as C, you can put it in a separate file in your sketch that uses the .c file extension. Files with that extension are compiled as C. You always must have that .ino file in the sketch, and that .ino file must be compiled as C++, but there doesn’t necessarily need to be anything in the file.

There isn’t much difference. I’m a C programmer as well and it’s easy to adapt. You don’t have to write your own C++ classes etc, just embrace what is there that makes your life easier; you can e.g. pass any standard type to Serial.print() without having to worry. With printf, you have to write different wrappers to print floats, integers, text etc.

And classes are not much different from structs; and you can still use structs.

1 Like

Ok so if I do: printf(“hello world”); the led print hello world?

Thanks at all for yours replies, can you recommend me a good starter kit for arduino and a good tutorial for start with arduino?
What about this:
Arduino Tutorial - Tutorialspoint ?

Since you can use C, you should be able to pick up Arduino coding easily. Download the IDE and look through some of the examples it provides. They’ll show you the form Arduino programs take, using setup and loop and hiding main behind the scenes.

Maybe the example was bad; printf does not exists but e.g. sprintf does.

In the PC world, printf() prints to the console; the console in the Arduino world is a terminal program and you can send data to it using Serial.print() / Serial.println().

PC program

printf("%s\n", "Hello world");
printf("%d\n", counter);

Arduino program

Serial.println("Hello world");
Serial.println(counter);

Note that you don’t have to provide format specifiers with the latter.