As a beginner, the syntax I'm being taught doesn't look the same as C or C++

Hi all,

Please forgive the long post, I would appreciate any input from the community.

I'm currently following TopTechBoy's (Paul Mcwhorter) Arduino tutorials on YouTube. As well as getting knowledge via many online sources.

I've learnt that Arduino can be programmed with C and C++ and even Java.

I want to start to expand my knowledge in a programming language specifically for the Arduino; I want to get a book or two and specifically knuckle down into one language for now.

What would be the best way to go about this?
I want to continue following Paul's videos, he really is a great, enthusiastic teacher and I find myself really enjoying learning from him.
I also, however, don't want to complicate things, as a beginner, with multiple languages and different syntax.

I'm not 100% sure what language Paul is teaching
Here is a snippet of some code I've written

//First ask, Brightness and colour

Serial.println(colourAsk);

while (Serial.available()==0) {

}

userLEDcolour=Serial.readString();



if (userLEDcolour.equals("red") || userLEDcolour.equals("Red")){

Serial.println(percentAsk);

while (Serial.available()==0)

{

}

userPercent=Serial.parseInt();

LEDbrightnessRed=2.55*userPercent;

analogWrite(redLEDpin, LEDbrightnessRed);

}

As im using println() and not printf() I assume this is Java?

My questions:

  • What language am I currently being taught?
  • Should I continue learning this language
  • **IF**I should be learning C or C++, should I jump straight to C++ (as this is an expansion of C)?[

As I bonus question (because this post isn't long enough and I haven't asked enough already) are there any books for beginner electronics anyone would recommend?

Thanks in advance
Rizzle

I've learnt that Arduino can be programmed with C and C++ and even Java.

It cannot be programmed in Java

As im using println() and not printf() I assume this is Java?

Your assumption is wrong. The Serial.println() function is part of the Arduino environment and is an extension of C/C++

The Arduino can be programmed in C and/or C++ so they are the languages to learn. Personally I never learned to program in C and went straight to C++

One piece of advice that you should heed is not to use Strings (uppercase S) even though they are supported, as the Arduino generally has limited memory. Instead use C style strings (lowercase s) as they are more suited to the small memory of the Arduino

Thanks for the help HeliBob!

I assumed Java as it was the prominent result when doing a Google search for println.

I suppose what's confusing me the most is the print function. As this is where most books and tutorials on C/++ start, and it differs from Serial.println.

I understand thanks to your post that Serial.print is part of the Arduino envirmonet and is C++ extension. Can I assume that the Serial.monitor and the Serial function is unique to the arduino IDE, where as if I was using an alternative C++ IDE, not related to Arduino, I would be using printf() and the data would be outputted in cmd/terminal?

Finally, is the syntax of the code snippet I posted in the OP C/++

Thanks again,
Rizzle

Can I assume that the Serial.monitor and the Serial function is unique to the arduino IDE, where as if I was using an alternative C++ IDE, not related to Arduino, I would be using printf() and the data would be outputted in cmd/terminal?

Correct. It is one of the confusing aspects of learning C/C++ and applying it to the Arduino

is the syntax of the code snippet I posted in the OP C/++

It uses Strings (objects created using the String library) so it is C++

I thank you again mate.
I shall start studying C++ and continue with the tutorials by Paul.

Have a nice Sunday brother