what is wrong with my problem?

if (distance11 > distance21) and (distance11 > distance31);

{ digitalWrite(IN1,HIGH); digitalWrite(IN2,LOW); analogWrite(ENA,255); digitalWrite(IN3,HIGH); digitalWrite(IN4,LOW); analogWrite(ENB,255); delay(100); } else; {} }

it said that "expected identifier before '(' taken " pros pls help this noob :disappointed_relieved:

if (distance11 > distance21) and (distance11 > distance31);
 {

Such a short line; so many things wrong. Lose the semicolon, match the parentheses.

Edit: And I'm not sure what the '#' is doing there, but lose it.

Starting # 'And' does not exist in C All the conditions within an 'if' must be between brackets No ’;' at end of IF or ELSE Empty {} has little use, remove the entire 'else; {}’ Use the code block markers to show code Show entire sketch

I suggest reading a book on C. We will help you, but you need to work on your basic skills.

And' does not exist in C

Yes, 'and' does.

Yes, 'and' does.

Well dang. You're right. Just learned something after years of programming.

You're right.

Imagine that. 8)

Note that it is a logical AND, not bitwise, so, for instance 0x03 and 0x02 returns 1, and not 2.

Nothing wrong with your problem, its a great problem!

Shame people don't realise "# if" is the same as "#if" though. Perhaps they've only seen #ifdef before, not realising its shorthand for

#ifdef __FOO__

// is the same as

#if defined(__FOO__)
// or
#                  if                   defined(__FOO__)

You just need to replace "and" with "&&" I think. Since you didn't post the whole code though I cannot be sure. Post the whole code.

AWOL:

And’ does not exist in C

Yes, ‘and’ does.

Please prove me wrong. I graduated with university in 1994 perhaps the ANSI C language has changed since then.

http://tigcc.ticalc.org/doc/keywords.html

RobvdVeer: Please prove me wrong. I graduated with university in 1994 perhaps the ANSI C language has changed since then.

The Arduino is programmed in C++, not ANSI 'C'.

You can prove it for yourself by compiling any sketch that uses and to perform a logical and.

PeterH:

RobvdVeer: Please prove me wrong. I graduated with university in 1994 perhaps the ANSI C language has changed since then.

The Arduino is programmed in C++, not ANSI 'C'.

You can prove it for yourself by compiling any sketch that uses and to perform a logical and.

I bow at your infinite wisdom. Though technically, i am still right because i said 'and' does not exist in C. A mere trifle of course. Let us continue with important matters.

geek fight!

PeterH:

RobvdVeer: Please prove me wrong. I graduated with university in 1994 perhaps the ANSI C language has changed since then.

The Arduino is programmed in C++, not ANSI 'C'. You can prove it for yourself by compiling any sketch that uses and to perform a logical and.

For me "and" in C/C++ it's a news (a good news). :D But if wiki tell us the truth: http://en.wikipedia.org/wiki/Iso646.h this statements are standard also in C: "The tokens were added to the standard in a 1995 amendment to the C90 standard"

@nid69ita… Geek Winner!

Doc
Edit for reasonable clarity.

Docedison: @nid69ita... Geek Winner... Doc

And what did I win? :grin: :grin:

The

geek fight!

comment from Retrolefty …

Doc

And what did I win?

smiley-mr-green smiley-mr-green

The comfort of being the biggest geek in the thread. Long live the geek!

nid69ita:

RobvdVeer: Please prove me wrong. I graduated with university in 1994 perhaps the ANSI C language has changed since then.

"The tokens were added to the standard in a 1995 amendment to the C90 standard"

Frack me, they indeed changed it just after i graduated. Bastards. XD Nevertheless it looks awful, it's rarely used, and in my opinion looks too much like Visual Basic,

I briefly looked at Visual Basic once... It Still looks complicated compared to C/C++, In particular the code bloat which is Micro$oft's Signature Trademark... Sigh.. Dos was ever so much better. I guess their mantra is to create confusion and then patch it until only Micro$oft truly understands it, to charge 3 X it's real value for the "largest patchwork quilt in the world". I hate it but I use it because too many other fools do... Too hard to find good EDA applications for Window$ but even harder to find good ones for any other OS except possibly a MAC and there is the same issue again... From Apple... 3X too much money for an "Exclusive OS" designed to be most difficult to use non Apple apps or any other non Apple devices.. thus forcing market share to be unequal... IMO.. Flame War, Anyone?

Doc

Docedison: Flame War, Anyone?

No, please =(

I think every programming language was created for a purpose (some for general purpose) and have a good history. You can dislike a single language but for me it's only a personal preference (for example I dislake Forth language) Personal opinions ^_^

And now we are very, very OT :D

RobvdVeer: Frack me, they indeed changed it just after i graduated. Bastards. XD Nevertheless it looks awful, it's rarely used, and in my opinion looks too much like Visual Basic,

:D :D :D :D :D :D :D :D :D :D :D :D 8) 8) 8) 8) 8) 8) 8) 8) 8) 8) 8)

Or just about any BASIC that I remember, not just the borrow-from-C newcomer.

Oh BTW, VB was made to do whatever all M$ software was made to do: make money off other people's ideas.