Understanding this line " ? HIGH : LOW; "

Really confusing for a newbie

And yet Arduino is supposed to be for beginners.

Is there a mechanism to provide feedback to the developers on such matters?

Good luck with that :slight_smile:

You probably should get a "Beginners guide to C" book or some such.


Rob

If it really was supposed to be for beginners, it wouldn’t use C.

Probably C next to assembly has been used for programming micro controllers for a very long time.

C/C++ has more available documentation, tutorials, books, and libraries than virtually any other language out there.
It is also one of the most space and performance efficient languages out there, which is of significant value on a platform with very limited memory space and processing power.

The simple fact is, if Arduino had used just about any other language to program in, for one reason or another it wouldn't have become nearly as popular as it has become.

ben10, and jraskell, - think about what you both just said: your responses are totally irrelevant to my point.

C really is too difficult for people who aren’t doing this stuff for a living. C is completely the wrong language for a beginners toy such as the arduino. Who cares what microcontrollers have been programmed in for a long time? Who cares what quantity of documentation and books etc are out there? Who cares about space efficiency and performance efficiency at all? That’s the last thing a beginner is concerned with. The only people that care about your points are proper programmers and engineers that do this sort of thing all day. For beginners, C is the wrong language.

Thanks for the clarifications! It is always refreshing when I find people who obviously know far more than I do about the topic in question, yet they will take the time, sometimes in great detail, to help me figure out something that already comes naturally to them. I have been on the other side of this fence more than once, and on certain other forums a similar question would have gotten me the terse answer "learn C" and ended there. I'm glad you folks are not like that! :slight_smile:

I am not sufficiently knowledgable to enter the debate on whether C or its variants are the best pick for Arduino, but what I HAVE learned so far is that the Arduino IDE does not support 'all' the code I have seen being used in other C++ references I have encountered when trying to look things up online for myself. So if I did get a book or tutorial on the basics of C++ it would effectively contain 'misinformation' for my purposes. That's why I am avoiding doing it.

In the subset of C++ code that does work on Arduino, does it work exactly the same way as would be used in other uses of C++? If for any reason the folks who created the Arduino IDE modified any of the commands' behavior, then trying to cross reference as a beginner would be a bad choice.

Whatever the case, in order to work with the Arduino platform I have to learn the language provided. (Unless someone wrote a MS Basic to Arduino code converter). :slight_smile:

Thanks.

So if I did get a book or tutorial on the basics of C++ it would effectively contain 'misinformation' for my purposes.

You need to understand what parts of the code are hardware specific (such as fopen()) and what parts are generic data manipulation/storage/allocation functions.

Most of the generic stuff will work on the Arduino. The hardware specific stuff will not.

There are some generic features that are not supported, mostly dealing with floating point processing, but most stuff is supported. An understanding of the hardware you are dealing with, and the limits that it comes with, will make understanding the language, and what is and is not supported easier.

@Ian:
To an extent, I agree with you, but hiding more complexity is just like finding an air-bubble when you're wallpapering - push it down, and it'll just pop up somewhere else, possibly in a different shape.

If you find a platform that is more forgiving of beginners, you'll almost certainly find that it is more complex and therefore more expensive. It will need more memory for a start.
You won't be able to migrate your project quite so simply or cheaply from breadboard to completed PCB.

Certainly, I've yet to come across a more cost-effective way of getting started than the Arduino (and yes, I know I do this stuff for a living) - PICs are even less friendly (they're either bare processors programmed in assembler, or comercial products running performance-sapping interpreters), and the last machine I designed from ground-up was a wire-wrapped 6809 which nearly drove me insane during debug (even with access to an in-circuit emulator).

I'd love a 20 MHz Z80 to tinker with, but it wouldn't be quite so easy to fiddle with the peripherals.

Remember, this is a hobbyist platform - trainer and evaluation boards do exist, but often they and/or their tools cost serious money.

I don't think Wiring is going to migrate to anything less C-like in the foreseeable future.

I say, get the C book. As noted before the stuff that you need to ignore are calls into the os for things like file management and displays. Perhaps there is a C for micro controllers book out there. From what I've seen, I've never run into a limitation of Arduino C++ that was not brought about by the hardware. And for all that stuff , the Arduino docs are excellent.

First, I don't agree that C is too hard for anybody not programming for a living.

Second, there are several microcontroller boards available based on BASIC, and none of them have become nearly as popular as Arduino, and there are several reasons for this.

  1. Those boards are far more limited than Arduinos BECAUSE they use BASIC. It's less efficient, both in terms of memory space and performance.
  2. Many experienced programmers will not bother working with BASIC, as such those boards lack the variety of third-party libraries that are available on the Arduino. Is there any other board out there that has something comparable to what Arduino has in the Playground? No.

Third, my second point and sub-points should make it perfectly clear that my original post was completely relevant. A beginners board that is ONLY used by beginners will never become popular for that very reason. And the current market completely supports that statement.

Actually, why isn’t it possible to use “Processing”, which is what occupied pretty much the entire first half of the arduino book I got, before it dawning on the reader that you don’t program the things using processing at all.

OK, so turning a totally 'blind' eye to what I am actually seeing - i.e. pretending I have never seen ANY C++ before, here is the first code from the first C++ tutorial on the first Google hit I got for "C++ beginner tutorial".

#include <iostream>

using namespace std;

int main()
{
  cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";
  cin.get();
}

How much or how little of it actually is usable by Arduino?

With a bit of fiddling, you can use almost the whole of this:

cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";

Well, I tested this code in Arduino. I got the following error messages on the verification:

iostream - no such file or directory

(it didn't like int main() but does not say why (love these cryptic messages!!)

'cout' not declared

'cin' not declared

Also, iostream, cout, and cin return "no reference" when I try to find them in the Reference section using Help/find in reference.

So basically, the whole sketch is a bust. This helps drive home my earlier point. Whenever I have tried to look outside of the Arduino Reference to understand the language, I only find things that have nothing to do with Arduino's version of C++. A complete beginner trying to use the arduino would stall out on the first page of that C++ Beginner tutorial because it starts right out teaching 'misinformation' when applied to Arduino.

AWOL:
With a bit of fiddling, you can use almost the whole of this:

cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";

Thanks, but since I am a beginner, I would not know what 'fiddling' to do to make it usable. :slight_smile:

So basically, the whole sketch is a bust.

A sketch doesn't have a "main", so you're confusing it with a program.

"cout" and "cin" are niceties provided by the operating system the Arduino doesn't have.

"iostream" is usually directed at something like "cout".

So, really there is no problem - you're trying to access stuff you haven't got.

Personally (being old-school C) I don't like the overloaded "<<" operator because it (to me) is short on meaning, but if you're interested see:
http://arduiniana.org/libraries/streaming/

AWOL:

So basically, the whole sketch is a bust.

A sketch doesn't have a "main", so you're confusing it with a program.

Does this mean I cannot name a function as "main" in Arduino? I seem to recall from my ancient Basic days that there were some words I was not allowed to use for certain things. Is there a list of these somewhere for Arduino?

Does this mean I cannot name a function as "main" in Arduino?

That's correct because the Arduino provides a "main" for you.
It also provides a function called "init".

Note that these are not names reserved by the language, like "for" or "return".

Here is the Arduino equivalent:

void setup() {
  Serial.begin(9600);
  Serial.println("HEY, you, I'm alive! Oh, and Hello World!");
}

void loop() { /*nothing to do in the loop*/ }

That looks a little more familiar! :slight_smile:

So what does "init" do? (another missing piece of info in the Arduino Reference).