My code won't compiled

Hello this is my final code end Solutions


//problem 1 you need to put ( , ) after  pinMode x, to work.
 { //problem.                                { //Solution.
 pinMode(13  OUTPUT);                pinMode(13,  OUTPUT);
  pinMode(8  INPUT);                     pinMode(8,  INPUT);
  pinMode(12  INPUT);  }               pinMode(12,  INPUT);  }


// commas after the Numbers if u don't u get this error.
In file included from sketch\sketch_jul16a.ino.cpp:1:0:
C:\Users\Simon\Desktop\sketch_jul15a\sketch_jul16a\sketch_jul16a.ino: In function 'void setup()':
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:44:16: error: expected ')' before numeric constant
 #define OUTPUT 0x1
                ^
C:\Users\Simon\Desktop\sketch_jul15a\sketch_jul16a\sketch_jul16a.ino:5:15: note: in expansion of macro 'OUTPUT'
   pinMode(13  OUTPUT);
               ^~~~~~
sketch_jul16a:5:21: error: too few arguments to function 'void pinMode(uint8_t, uint8_t)'
   pinMode(13  OUTPUT);
                     ^
In file included from sketch\sketch_jul16a.ino.cpp:1:0:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:134:6: note: declared here
 void pinMode(uint8_t pin, uint8_t mode);
      ^~~~~~~
In file included from sketch\sketch_jul16a.ino.cpp:1:0:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:43:15: error: expected ')' before numeric constant
 #define INPUT 0x0
               ^
C:\Users\Simon\Desktop\sketch_jul15a\sketch_jul16a\sketch_jul16a.ino:6:14: note: in expansion of macro 'INPUT'
   pinMode(8  INPUT);
              ^~~~~
sketch_jul16a:6:19: error: too few arguments to function 'void pinMode(uint8_t, uint8_t)'
   pinMode(8  INPUT);
                   ^
In file included from sketch\sketch_jul16a.ino.cpp:1:0:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:134:6: note: declared here
 void pinMode(uint8_t pin, uint8_t mode);
      ^~~~~~~
In file included from sketch\sketch_jul16a.ino.cpp:1:0:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:43:15: error: expected ')' before numeric constant
 #define INPUT 0x0
               ^
C:\Users\Simon\Desktop\sketch_jul15a\sketch_jul16a\sketch_jul16a.ino:7:15: note: in expansion of macro 'INPUT'
   pinMode(12  INPUT);
               ^~~~~
sketch_jul16a:7:20: error: too few arguments to function 'void pinMode(uint8_t, uint8_t)'
   pinMode(12  INPUT);
                    ^
In file included from sketch\sketch_jul16a.ino.cpp:1:0:
C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:134:6: note: declared here
 void pinMode(uint8_t pin, uint8_t mode);
      ^~~~~~~
exit status 1
too few arguments to function 'void pinMode(uint8_t, uint8_t)'

//problem 2 set int global so if u don't set int ass global your arguments want function

//so how to set int global u put it before 
void setup()


//exempel 
( int qe = 0;

void setup()
{
  pinMode(13,  OUTPUT);
  pinMode(8,  INPUT);
  pinMode(12,  INPUT);
  Serial.begin(2400);
} )



// end you need to check your math 

//exempel 
( qe = qe + 1; )


//full code

[code]
int qe = 0;

void setup()
{
  pinMode(13,  OUTPUT);
  pinMode(8,  INPUT);
  pinMode(12,  INPUT);
  Serial.begin(2400);
}

void loop()
{
  int inpu = digitalRead(8);
  int id = digitalRead(12);
  
  if (inpu == HIGH)
  {
    qe = qe + 1;
  }
  else if (id == HIGH)
  {
    qe = 0;
  }
  else if (qe >= 1)
  {
    digitalWrite(13, HIGH);
  }
  else if (qe <= 0)
  {
    digitalWrite(13, LOW);
  }

 Serial.println(qe);
  delay(1);

  
}
[/code]

What does "broken" mean?

Do you have a comma phobia?

Did you forget '=' ?

Because there, you've got too many '=' !

Hi, welcome to the forum.

Could you please clarify what you mean by broken?
I will make an assumption that your variables are not updating in loop. This is because you update i and l once only in setup().

Once this is done, the variables are not being updated in loop().
What you may want to try is:


// global declaration before setup
const int i = 8;
consrt int l = 9;

//in loop
if ( digitalRead (i) >= HIGH ){ qe + 1 ;}
else if ( digitalRead (l) >= HIGH ){ qe == 0;}

Note:

  • the variables i and l look very similar to each other and will cause unexpected confusion later. Give them long names
  • the >= High doesn't make sense

The IDE gives you a handy control to copy the error messages, but you posted a screenshot instead.

Your topic was moved to its current location as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

It will help you get the best out of the forum in the future.

Thank you

Did you forget '=' ?

qe =+ 1 ? (1)
= qe + 1 ? (2)

None of the above.

qe += 1;

If the above above function can have comma separated arguments (12, OUTPUT), why is not the same for the following function?

 digitalWrite( 13 HIGH );
Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino Uno"





















In file included from sketch\sketch_jul19a.ino.cpp:1:0:

C:\Users\Simon\Desktop\sketch_jul15a\sketch_jul19a\sketch_jul19a.ino: In function 'void setup()':

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:44:16: error: expected ')' before numeric constant

 #define OUTPUT 0x1

                ^

C:\Users\Simon\Desktop\sketch_jul15a\sketch_jul19a\sketch_jul19a.ino:2:13: note: in expansion of macro 'OUTPUT'

 pinMode(12  OUTPUT);

             ^~~~~~

sketch_jul19a:2:19: error: too few arguments to function 'void pinMode(uint8_t, uint8_t)'

 pinMode(12  OUTPUT);

                   ^

In file included from sketch\sketch_jul19a.ino.cpp:1:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:134:6: note: declared here

 void pinMode(uint8_t pin, uint8_t mode);

      ^~~~~~~

In file included from sketch\sketch_jul19a.ino.cpp:1:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:44:16: error: expected ')' before numeric constant

 #define OUTPUT 0x1

                ^

C:\Users\Simon\Desktop\sketch_jul15a\sketch_jul19a\sketch_jul19a.ino:3:13: note: in expansion of macro 'OUTPUT'

 pinMode(13  OUTPUT);

             ^~~~~~

sketch_jul19a:3:19: error: too few arguments to function 'void pinMode(uint8_t, uint8_t)'

 pinMode(13  OUTPUT);

                   ^

In file included from sketch\sketch_jul19a.ino.cpp:1:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:134:6: note: declared here

 void pinMode(uint8_t pin, uint8_t mode);

      ^~~~~~~

In file included from sketch\sketch_jul19a.ino.cpp:1:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:43:15: error: expected ')' before numeric constant

 #define INPUT 0x0

               ^

C:\Users\Simon\Desktop\sketch_jul15a\sketch_jul19a\sketch_jul19a.ino:4:14: note: in expansion of macro 'INPUT'

 pinMode(8    INPUT);

              ^~~~~

sketch_jul19a:4:19: error: too few arguments to function 'void pinMode(uint8_t, uint8_t)'

 pinMode(8    INPUT);

                   ^

In file included from sketch\sketch_jul19a.ino.cpp:1:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:134:6: note: declared here

 void pinMode(uint8_t pin, uint8_t mode);

      ^~~~~~~

In file included from sketch\sketch_jul19a.ino.cpp:1:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:43:15: error: expected ')' before numeric constant

 #define INPUT 0x0

               ^

C:\Users\Simon\Desktop\sketch_jul15a\sketch_jul19a\sketch_jul19a.ino:5:14: note: in expansion of macro 'INPUT'

 pinMode(9    INPUT);

              ^~~~~

sketch_jul19a:5:19: error: too few arguments to function 'void pinMode(uint8_t, uint8_t)'

 pinMode(9    INPUT);

                   ^

In file included from sketch\sketch_jul19a.ino.cpp:1:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:134:6: note: declared here

 void pinMode(uint8_t pin, uint8_t mode);

      ^~~~~~~

C:\Users\Simon\Desktop\sketch_jul15a\sketch_jul19a\sketch_jul19a.ino: In function 'void loop()':

sketch_jul19a:13:6: error: 'i' was not declared in this scope

 if ( i = HIGH ){  qe += 1 ;}

      ^

sketch_jul19a:13:19: error: 'qe' was not declared in this scope

 if ( i = HIGH ){  qe += 1 ;}

                   ^~

sketch_jul19a:14:11: error: 'l' was not declared in this scope

 else if ( l = HIGH ){ qe = 0;}

           ^

sketch_jul19a:14:23: error: 'qe' was not declared in this scope

 else if ( l = HIGH ){ qe = 0;}

                       ^~

sketch_jul19a:15:11: error: 'qe' was not declared in this scope

 else if ( qe >= 1){  digitalWrite( 13 HIGH );  }

           ^~

In file included from sketch\sketch_jul19a.ino.cpp:1:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:40:14: error: expected ')' before numeric constant

 #define HIGH 0x1

              ^

C:\Users\Simon\Desktop\sketch_jul15a\sketch_jul19a\sketch_jul19a.ino:15:39: note: in expansion of macro 'HIGH'

 else if ( qe >= 1){  digitalWrite( 13 HIGH );  }

                                       ^~~~

sketch_jul19a:15:44: error: too few arguments to function 'void digitalWrite(uint8_t, uint8_t)'

 else if ( qe >= 1){  digitalWrite( 13 HIGH );  }

                                            ^

In file included from sketch\sketch_jul19a.ino.cpp:1:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:135:6: note: declared here

 void digitalWrite(uint8_t pin, uint8_t val);

      ^~~~~~~~~~~~

In file included from sketch\sketch_jul19a.ino.cpp:1:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:41:14: error: expected ')' before numeric constant

 #define LOW  0x0

              ^

C:\Users\Simon\Desktop\sketch_jul15a\sketch_jul19a\sketch_jul19a.ino:16:39: note: in expansion of macro 'LOW'

 else if (qe <= 0 ){  digitalWrite( 13 LOW  );  }

                                       ^~~

sketch_jul19a:16:44: error: too few arguments to function 'void digitalWrite(uint8_t, uint8_t)'

 else if (qe <= 0 ){  digitalWrite( 13 LOW  );  }

                                            ^

In file included from sketch\sketch_jul19a.ino.cpp:1:0:

C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:135:6: note: declared here

 void digitalWrite(uint8_t pin, uint8_t val);

      ^~~~~~~~~~~~

exit status 1

too few arguments to function 'void pinMode(uint8_t, uint8_t)'



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

happy xd :slight_smile:

And now you've posted error messages that do not relate to the code you posted.

Why not fix the problems that have already been pointed-out, and then if you've still got problems, post the code, and post the error messages?

1 Like

I overlook that until now.

do you know if this is a problem?

I em nu her so I don't no.

Have you fixed the naming of your variables to more meaningful names? Easier to see errors if we are not trying to tell the difference between i and l

Please correct you code, run it and post the new code and errors if you still have problems.

I am new here so I dont know .. ????

I am new here; so, I don't know. (???)

@gru2x2
Please, post the correct forms of the following lines to get more help.

pinMode( 12  OUTPUT );
pinMode( 13  OUTPUT );
pinMode( 8    INPUT );
pinMode( 9    INPUT );

Add commas:

pinMode( 12  OUTPUT );
pinMode( 13  OUTPUT );
pinMode( 8    INPUT );
pinMode( 9    INPUT );

Move these outside of setup() to make them global and they should NOT be constant:

const int qe = 0;
const int i  = digitalRead(8) ;
const int l  = digitalRead(9) ;

Multiple issues below:

  1. '=' is assignment. '==' is comparison.
  2. i and l never get changed during loop()
  3. missing a comma in digitalWrite() calls
if ( i = HIGH ){  qe += 1 ;}
else if ( l = HIGH ){ qe = 0;}
else if ( qe >= 1){  digitalWrite( 13 HIGH );  }
else if (qe <= 0 ){  digitalWrite( 13 LOW  );  }

In general:

  1. avoid single character variables, with the possible exception in loops as an iterator
  2. not sure about the else if statements because you have not described what you want your program to do
  3. you need to work on understanding basic C++ program structure, semantics, and syntax

It looks like this is what you intended to write:

int qe = 0;

void setup()
{
  pinMode(12, OUTPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(8, INPUT);
  pinMode(9, INPUT);
}

void loop()
{
  int i = digitalRead(8);
  int l = digitalRead(9);
  
  if (i == HIGH)
  {
    qe = qe + 1;
  }
  else if (l == HIGH)
  {
    qe = 0;
  }
  else if (qe >= 1)
  {
    digitalWrite(LED_BUILTIN, HIGH);
  }
  else if (qe <= 0)
  {
    digitalWrite(LED_BUILTIN, LOW);
  }
}
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.