Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 02:39:25 pm
Thank you for the code, but it still doesn't work! It says:
In function 'void loop()':
error: 'getTiltPosition' was not declared in this scope

this is the code:
Code:
int tilt_s1 = 2;
int tilt_s2 = 3;
int E1 = 4;   
int M1 = 5;
int E2 = 7;                         
int M2 = 6; 

void setup()
{
   pinMode(M1, OUTPUT);   
   pinMode(M2, OUTPUT);
   pinMode(tilt_s1, INPUT);
   pinMode(tilt_s2, INPUT);
   Serial.begin(9600);
}
void loop(){
  int pos = getTiltPos();
  Serial.println(pos);
  delay(200);
  if (pos == 3)
  {
  for(int value = 0 ; value <= 200; value+=5)
  {
    digitalWrite(M1, HIGH); 
    digitalWrite(M2, HIGH);
    analogWrite(E2, 200);   
    analogWrite(E1, 200);   //PLL Speed Control
    delay(30);
  }
 
 }
 else{
  for(int value = 0 ; value <= 100; value+=5)
  {
    digitalWrite(M1, LOW); 
    digitalWrite(M2, LOW);   
    analogWrite(E1, 100);
    analogWrite(E2, 100);   //PLL Speed Control
    delay(30);
  } 

 }
 
}
2  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:53:59 pm
So

 
Quote
//Arduino PLL Speed Control:
int E1 = 4;   
int M1 = 5; 
int E2 = 7;                         
int M2 = 6;
int tilt_s1 = 2;
int tilt_s2 = 3;

void setup()
{
 pinMode(M1, OUTPUT);
 pinMode(M2, OUTPUT);
 pinMode(tilt_s1, INPUT);
 pinMode(tilt_s2, INPUT);
 Serial.begin(9600);   
}
 
void loop(){
  int position = getTiltPosition();
  Serial.println(position);
  delay(200);
}

int getTiltPosition(){
  int s1 = digitalRead(tilt_s1);
  int s2 = digitalRead(tilt_s2);
  return (s1 << 1) | s2;
 
}
 void engine()
{
  if (position == 3)
  {
  int value
  for(value = 0 ; value <= 1; value+=5)
  {
    digitalWrite(M1, HIGH); 
    digitalWrite(M2, HIGH);
    analogWrite(E2, 1);   
    analogWrite(E1, 1);   //PLL Speed Control
    delay(30);
  }
 
 } 
 
     
{
else
  int value
  for(value = 0 ; value <= 1; value+=5)
  {
    digitalWrite(M1, LOW); 
    digitalWrite(M2, LOW);   
    analogWrite(E1, 1);
    analogWrite(E2, 1);   //PLL Speed Control
    delay(30);
  } 


 
 
3  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:44:32 pm
Quote
You can't turn an if statement into a function, you can only nest it within the function.

the statement is = if (position == 3)
4  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:39:26 pm
Because i don't understand how you nest a statement into a code!
5  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:32:56 pm
but if i turn
Code:
if (position == 3)
in to
Code:
int if (position == 3)

it stills shows the error of expected unqualified-id before if
6  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:28:51 pm
Can you give me an example of how i am supposed to do it because i don't have much time left!
7  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:25:47 pm
Thank You!

But now its shows another error!
Code:
//Arduino PLL Speed Control:
int E1 = 4;   
int M1 = 5; 
int E2 = 7;                         
int M2 = 6;
int tilt_s1 = 2;
int tilt_s2 = 3;

void setup()
{
 pinMode(M1, OUTPUT);
 pinMode(M2, OUTPUT);
 pinMode(tilt_s1, INPUT);
 pinMode(tilt_s2, INPUT);
 Serial.begin(9600);   
}
 
void loop(){
  int position = getTiltPosition();
  Serial.println(position);
  delay(200);
 

int getTiltPosition(){
  int s1 = digitalRead(tilt_s1);
  int s2 = digitalRead(tilt_s2);
  return (s1 << 1) | s2;
 
}
if (position == 3)
  {
  int value
  for(value = 0 ; value <= 1; value+=5)
  {
    digitalWrite(M1, HIGH); 
    digitalWrite(M2, HIGH);
    analogWrite(E2, 1);   
    analogWrite(E1, 1);   //PLL Speed Control
    delay(30);
  }
 
 } 
 
     
{
else
  int value
  for(value = 0 ; value <= 1; value+=5)
  {
    digitalWrite(M1, LOW); 
    digitalWrite(M2, LOW);   
    analogWrite(E1, 1);
    analogWrite(E2, 1);   //PLL Speed Control
    delay(30);
  } 

 }
 
 

ino: In function 'void loop()':
error: 'getTiltPosition' was not declared in this scope
error: a function-definition is not allowed here before '{' token
error: expected initializer before 'for'
error: 'value' was not declared in this scope
error: expected `;' before ')' token
error: 'else' without a previous 'if'
error: expected initializer before 'for'
error: 'value' was not declared in this scope
error: expected `;' before ')' token
8  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:16:40 pm
sorry I am a newbie. So how do you put it in a function (i'm dutch and 12 years so sorry for my english)
9  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:13:06 pm
how do you make the if statement in a function?
All code to be executed needs to be in a function.

your if statement is not in a function.

Also, you should be using == rather than = in the if.
10  Using Arduino / Programming Questions / Re: expected unqualified-id before 'if' on: June 09, 2013, 01:11:49 pm
it still doesn't work

error: expected unqualified-id before 'if'
11  Using Arduino / Programming Questions / expected unqualified-id before 'if' on: June 09, 2013, 01:09:27 pm
the code doesn't work!

Code:
//Arduino PLL Speed Control:
int E1 = 4;   
int M1 = 5; 
int E2 = 7;                         
int M2 = 6;
int tilt_s1 = 2;
int tilt_s2 = 3;

void setup()
{
 pinMode(M1, OUTPUT);
 pinMode(M2, OUTPUT);
 pinMode(tilt_s1, INPUT);
 pinMode(tilt_s2, INPUT);
 Serial.begin(9600);   
}
 
void loop(){
  int position = getTiltPosition();
  Serial.println(position);
  delay(200);


int getTiltPosition(){
  int s1 = digitalRead(tilt_s1);
  int s2 = digitalRead(tilt_s2);
  return (s1 << 1) | s2;
}

if (position = 3)
  {
  int value
  for(value = 0 ; value <= 1; value+=5)
  {
    digitalWrite(M1, HIGH); 
    digitalWrite(M2, HIGH);
    analogWrite(E2, 1);   
    analogWrite(E1, 1);   //PLL Speed Control
    delay(30);
  }
 
  }   
{
else
  int value
  for(value = 0 ; value <= 1; value+=5)
  {
    digitalWrite(M1, LOW); 
    digitalWrite(M2, LOW);   
    analogWrite(E1, 1);
    analogWrite(E2, 1);   //PLL Speed Control
    delay(30);
  } 

}
12  Using Arduino / Programming Questions / Re: HC-SR04-LCD on: January 29, 2013, 12:05:39 pm
Yes that worked.
13  Using Arduino / Programming Questions / Re: HC-SR04-LCD on: January 29, 2013, 12:01:26 pm
Yes!
14  Using Arduino / Programming Questions / Re: HC-SR04-LCD on: January 29, 2013, 11:51:48 am
No because i don't control the c++ language yet. Can you help my with the code?

Cekstuffertz
15  Using Arduino / Programming Questions / Re: HC-SR04-LCD on: January 29, 2013, 11:46:48 am
Quote
Is it possible to with the HC-SR04 to develop a system that allows you as the distance e.g.. lower than 40 cm you can control a lcd screen for a certain time?
It is possible to use a HC-SR04 to measure distances. It is possible to display that distance on an LCD screen. It would be helpful if you explained the "control a lcd screen" part. Usually, LCD screens are not unruly devices that need controlling. But, when they are, controlling them only for a certain time is not a good idea.
When the distance is lower then e.g.. 40 the lcd screen have to show a text for 30 seconds like:"Good job!"
Pages: [1] 2 3