user6379: This is my first time to try program arduino, and I am clueless. I have a friend who told me about things work, and he told me the programming language is C (or similar to C) which we have learned in our class. I just program as my friend examples, but it doesn't work and return error codes about expected ; before ( or ) before ; etc.
I'm not sure why this wont work. This is the hardware (simulated) I going to make.
     
here's the code:
#define dw 8; //buttons down
#define ri 9; //buttons right
#define le 10; //buttons left
#define up 11; //buttons up
#define ok 12; //buttons ok
#define mn 13; //buttons menu
#include <LiquidCrystal.h>
LiquidCrystal lcd(6,5,4,3,2,1);
int i=0;
char input[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

void setup()
{
  pinMode(dw, INPUT);
  pinMode(ri, INPUT);
  pinMode(le, INPUT);
  pinMode(up, INPUT);
  pinMode(ok, INPUT);
  pinMode(mn, INPUT);  
}
void intext()
{
  int c=0, lim=16;
  for(i=0;i<lim;)
  {
    lcd.setCursor(c,1);
    input[i]=97;
    if(dw=HIGH)
    {
      if(input[i]>122)
        input[i]=97;
      input[i]=input[i]+1;
      lcd.print(input[i]);
    }
    if(up=HIGH)
    {
      if(input[i]>97)
        input[i]=122;
      input[i]=input[i]-1;
      lcd.print(input[i]);
    }
    if(ri=HIGH)
    {
      c=c+1;
      lcd.setCursor(c,1);
      lcd.print(input[i]);      
    }
    if(le=HIGH)
    {
      c=c-1;
      lcd.setCursor(c,1);
      lcd.print(input[i]);
    }
    if(ok=HIGH)
    {
      lim=i+1;
    }
  }
}

void loop()
{
  lcd.begin(16,2);
  lcd.setCursor(0,0);
  lcd.print("Masukan kata:");
  intext();
}

I have no idea why it wouldn't work. I'm sorry if I'm too stupid to understand.
Thank you!
Edit: oh yeah, the errors, here:
  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
Arduino: 1.0.6 (Windows NT (unknown)), Board: "Arduino Uno"
programyuhu.ino: In function 'void setup()':
programyuhu:14: error: expected `)' before ';' token
programyuhu:14: error: expected primary-expression before ',' token
programyuhu:14: error: expected `;' before ')' token
programyuhu:15: error: expected `)' before ';' token
programyuhu:15: error: expected primary-expression before ',' token
programyuhu:15: error: expected `;' before ')' token
programyuhu:16: error: expected `)' before ';' token
programyuhu:16: error: expected primary-expression before ',' token
programyuhu:16: error: expected `;' before ')' token
programyuhu:17: error: expected `)' before ';' token
programyuhu:17: error: expected primary-expression before ',' token
programyuhu:17: error: expected `;' before ')' token
programyuhu:18: error: expected `)' before ';' token
programyuhu:18: error: expected primary-expression before ',' token
programyuhu:18: error: expected `;' before ')' token
programyuhu:19: error: expected `)' before ';' token
programyuhu:19: error: expected primary-expression before ',' token
programyuhu:19: error: expected `;' before ')' token
programyuhu.ino: In function 'void intext()':
programyuhu:28: error: expected `)' before ';' token
programyuhu:28: error: expected primary-expression before '=' token
programyuhu:28: error: expected `;' before ')' token
programyuhu:35: error: expected `)' before ';' token
programyuhu:35: error: expected primary-expression before '=' token
programyuhu:35: error: expected `;' before ')' token
programyuhu:42: error: expected `)' before ';' token
programyuhu:42: error: expected primary-expression before '=' token
programyuhu:42: error: expected `;' before ')' token
programyuhu:48: error: expected `)' before ';' token
programyuhu:48: error: expected primary-expression before '=' token
programyuhu:48: error: expected `;' before ')' token
programyuhu:54: error: expected `)' before ';' token
programyuhu:54: error: expected primary-expression before '=' token
programyuhu:54: error: expected `;' before ')' token


user3879: The errors are in your #define statements.
These should not have ; as they are not executable statements

user84: In C and in C++, #define is not an instruction of the language, but a directive of the pre-processor.
What it does is define a "macro" which will be replaced everywhere it appears later on in the source file.
For instance:
#define DUMMY 152

int x = x + DUMMY;
myfunction(DUMMY);

will be changed, before compilation, into:
int x = x + 152;
myfuntion(152);

In the example above, DUMMY is replaced everywhere by what follows it in the  #define line, i.e. 152.
As pre-processor directive is not an instruction, it shall not be ended by ;. If you add ; at the end of a #define, then it will be part of the replacement:
#define DUMMY 152;

int x = x + 152;;
myfuntion(152;);

As you can see now, DUMMY is replaced by 152;, not just 152.
So the solution in you example is to remove all ; that are at the end of #define lines:
//buttons down
#define dw 8
//buttons right
#define ri 9
//buttons left
#define le 10
//buttons up
#define up 11
//buttons ok
#define ok 12
//buttons menu
#define mn 13

Note that comments should also be removed from the #define otherwise they would also appear everywhere the replacements are done.

user368: Here's the first line of your code:

#define dw 8; //buttons down


Here's the first error line:

pinMode(dw, INPUT);


Let's put them together and see what we get:
pinMode(8; //buttons down, INPUT);

That's not valid C++. Using the output I've shown you, modify the input until it looks correct. And then keep doing it until the code compiles.

6379: <p>This is my first time to try program arduino, and I am clueless. I have a friend who told me about things work, and he told me the programming language is C (or similar to C) which we have learned in our class. I just program as my friend examples, but it doesn't work and return error codes about expected ; before ( or ) before ; etc.</p>

<p>I'm not sure why this wont work. This is the hardware (simulated) I going to make.
     <img src="https://i.stack.imgur.com/HnyKf.jpg" alt="hw-planned"></p>

<p>here's the code:</p>

<pre><code>#define dw 8; //buttons down
#define ri 9; //buttons right
#define le 10; //buttons left
#define up 11; //buttons up
#define ok 12; //buttons ok
#define mn 13; //buttons menu
#include &lt;LiquidCrystal.h&gt;
LiquidCrystal lcd(6,5,4,3,2,1);
int i=0;
char input[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

void setup()
{
  pinMode(dw, INPUT);
  pinMode(ri, INPUT);
  pinMode(le, INPUT);
  pinMode(up, INPUT);
  pinMode(ok, INPUT);
  pinMode(mn, INPUT);  
}
void intext()
{
  int c=0, lim=16;
  for(i=0;i&lt;lim;)
  {
    lcd.setCursor(c,1);
    input[i]=97;
    if(dw=HIGH)
    {
      if(input[i]&gt;122)
        input[i]=97;
      input[i]=input[i]+1;
      lcd.print(input[i]);
    }
    if(up=HIGH)
    {
      if(input[i]&gt;97)
        input[i]=122;
      input[i]=input[i]-1;
      lcd.print(input[i]);
    }
    if(ri=HIGH)
    {
      c=c+1;
      lcd.setCursor(c,1);
      lcd.print(input[i]);      
    }
    if(le=HIGH)
    {
      c=c-1;
      lcd.setCursor(c,1);
      lcd.print(input[i]);
    }
    if(ok=HIGH)
    {
      lim=i+1;
    }
  }
}

void loop()
{
  lcd.begin(16,2);
  lcd.setCursor(0,0);
  lcd.print("Masukan kata:");
  intext();
}
</code></pre>

<p>I have no idea why it wouldn't work. I'm sorry if I'm too stupid to understand.
Thank you!</p>

<p>Edit: oh yeah, the errors, here:</p>

<pre><code>  This report would have more information with
  "Show verbose output during compilation"
  enabled in File &gt; Preferences.
Arduino: 1.0.6 (Windows NT (unknown)), Board: "Arduino Uno"
programyuhu.ino: In function 'void setup()':
programyuhu:14: error: expected `)' before ';' token
programyuhu:14: error: expected primary-expression before ',' token
programyuhu:14: error: expected `;' before ')' token
programyuhu:15: error: expected `)' before ';' token
programyuhu:15: error: expected primary-expression before ',' token
programyuhu:15: error: expected `;' before ')' token
programyuhu:16: error: expected `)' before ';' token
programyuhu:16: error: expected primary-expression before ',' token
programyuhu:16: error: expected `;' before ')' token
programyuhu:17: error: expected `)' before ';' token
programyuhu:17: error: expected primary-expression before ',' token
programyuhu:17: error: expected `;' before ')' token
programyuhu:18: error: expected `)' before ';' token
programyuhu:18: error: expected primary-expression before ',' token
programyuhu:18: error: expected `;' before ')' token
programyuhu:19: error: expected `)' before ';' token
programyuhu:19: error: expected primary-expression before ',' token
programyuhu:19: error: expected `;' before ')' token
programyuhu.ino: In function 'void intext()':
programyuhu:28: error: expected `)' before ';' token
programyuhu:28: error: expected primary-expression before '=' token
programyuhu:28: error: expected `;' before ')' token
programyuhu:35: error: expected `)' before ';' token
programyuhu:35: error: expected primary-expression before '=' token
programyuhu:35: error: expected `;' before ')' token
programyuhu:42: error: expected `)' before ';' token
programyuhu:42: error: expected primary-expression before '=' token
programyuhu:42: error: expected `;' before ')' token
programyuhu:48: error: expected `)' before ';' token
programyuhu:48: error: expected primary-expression before '=' token
programyuhu:48: error: expected `;' before ')' token
programyuhu:54: error: expected `)' before ';' token
programyuhu:54: error: expected primary-expression before '=' token
programyuhu:54: error: expected `;' before ')' token
</code></pre>
 3879: <p>The errors are in your <code>#define</code> statements.</p>

<p>These should not have <code>;</code> as they are not executable statements</p>
 84: <p>In C and in C++, <code>#define</code> is not an instruction of the language, but a directive of the <strong>pre-processor</strong>.</p>

<p>What it does is define a "macro" which will be replaced everywhere it appears later on in the source file.</p>

<p>For instance:</p>

<pre><code>#define DUMMY 152

int x = x + DUMMY;
myfunction(DUMMY);
</code></pre>

<p>will be changed, before compilation, into:</p>

<pre><code>int x = x + 152;
myfuntion(152);
</code></pre>

<p>In the example above, <code>DUMMY</code> is replaced everywhere by what follows it in the  <code>#define</code> line, i.e. 152.</p>

<p>As pre-processor directive is not an instruction, it shall not be ended by <code>;</code>. If you add <code>;</code> at the end of a <code>#define</code>, then it will be part of the replacement:</p>

<pre><code>#define DUMMY 152;

int x = x + 152;;
myfuntion(152;);
</code></pre>

<p>As you can see now, <code>DUMMY</code> is replaced by <code>152;</code>, not just <code>152</code>.</p>

<p>So the solution in you example is to remove all <code>;</code> that are at the end of <code>#define</code> lines:</p>

<pre><code>//buttons down
#define dw 8
//buttons right
#define ri 9
//buttons left
#define le 10
//buttons up
#define up 11
//buttons ok
#define ok 12
//buttons menu
#define mn 13
</code></pre>

<p>Note that comments should also be removed from the <code>#define</code> otherwise they would also appear everywhere the replacements are done.</p>
 368: <p>Here's the first line of your code:</p>

<blockquote>
<pre><code>#define dw 8; //buttons down
</code></pre>
</blockquote>

<p>Here's the first error line:</p>

<blockquote>
<pre><code>pinMode(dw, INPUT);
</code></pre>
</blockquote>

<p>Let's put them together and see what we get:</p>

<pre><code>pinMode(8; //buttons down, INPUT);
</code></pre>

<p>That's not valid C++. Using the output I've shown you, modify the input until it looks correct. And then keep doing it until the code compiles.</p>
