Hello i am a new person to arduino. I wanted to ask if i can write arduino codes with c++ knowledge. And also if i want to write arduino codes, should i use C or C++ ??
Welcome to the forum
The Arduino uses C++ with hardware specific extensions but you are free to use plain C if that is what you want to do
Can i write arduino with c++ ?
Yes
What else do you need as answer?
If you need a more specific answer you should ask more specific.
I different interpretation of your question "can I write Arduino with C++" is
void setup() {
Serial.begin(115200);
Serial.println("Arduino");
}
void loop() {
}
From someone who is currently learning C/C++, if you use the Arduino IDE to write your code you will notice some differences between what you may be used to writing code in something like VS compared to the Arduino environment. First and foremost, the Arduino IDE adds in a setup() function and a loop() function but takes away your visual of the main() function. Also not all the C/C++ libraries are supported in the Arduino IDE.
Basically the Arduino IDE hides the main() function and just uses setup() and loop(). Setup is called once and loop is a for ( ; ; ) or while(1). There is also a big library that gets added without having to include it called <arduino.h>.
I imagine you will have an easier time getting used to the Arduino way of coding vs someone who is trying to learn C/C++ after being introduced to the Arduino way of coding. I know the first few lessons in C++ I was really confused and was asking where the loop() was.
Also, printf() isn't natively supported.
On some Arduino-compatible boards, like ESP8266/32, Serial.printf() is supported.