Go Down

Topic: "error expected unqualified-id before numeric constant" boolean (Read 71 times) previous topic - next topic

roberto03

Got this error message when trying to compiling:
"error expected unqualified-id before numeric constant" at the line starting with "boolean".

I already looked at other similar posts but it doesn't fix the bug.
Thank you for any suggestion.

The first part of the code is:
Code: [Select]


#include <Servo.h>
#include <IRremote.h>

const int irReceivePin = 2;   // pin connected to IR detector output
IRrecv irrecv(irReceivePin);    // create the IR library
decode_results results;         // IR data goes here

const int rightMotorPin = 9;  // Connected to right servo
const int leftMotorPin = 10;  // Connected to left servo

Servo rightServo;
Servo leftServo;

int rightSpeed = 90;
int leftSpeed = 90;

long keyCode = 0;
boolean DEBUG = true; // set to true if you want to display the Debug output

void setup()
{
  if(DEBUG){
    Serial.begin(9600);
  }


spycatcher2k

Drew.
http://www.uk-pcb.co.uk - My UK Based PCB Fab & Assembly Company
Design & Assembly work undertaken - Arduino repairs & testing - PM for details.

roberto03

Thank you, here's the whole code.

Code: [Select]


#include <Servo.h>
#include <IRremote.h>

const int irReceivePin = 2;   // pin connected to IR detector output
IRrecv irrecv(irReceivePin);    // create the IR library
decode_results results;         // IR data goes here

const int rightMotorPin = 9;  // Connected to right servo
const int leftMotorPin = 10;  // Connected to left servo

Servo rightServo;
Servo leftServo;

int rightSpeed = 90;
int leftSpeed = 90;

long keyCode = 0;
// set to true if you want to display the Debug output
boolean DEBUG = true;

void setup()
{
  if(DEBUG){
    Serial.begin(9600);
  }

  irrecv.enableIRIn();              // Start the IR receiver

  leftServo.attach(9);
  rightServo.attach(10);
 
  pinMode(rightMotorPin, OUTPUT);
  pinMode(leftMotorPin, OUTPUT);
}

void loop() {
  if( irrecv.decode(&results) )

  {
    keyCode=results.value;
    if(keyCode != -1)
    {
      switch (keyCode){
        case 50174055:  // Replace this code with the one from your remote!
        Serial.println("Forward");
        leftSpeed-=1;  // Opposite values propel the wheels forward
        rightSpeed+=1;
        break;
       
        case 50182215:  // Replace this code with the one from your remote!
        Serial.println("Backward");
        leftSpeed+=1;  // Opposite values propel the wheels backward
        rightSpeed-=1;
        break;
       
        case 50168955:  // Replace this code with the one from your remote!
        Serial.println("Stop");
        leftSpeed=90;  // A value of 90 stops the servos from turning
        rightSpeed=90;
        break;

        case 50152125:  // Replace this code with the one from your remote!
        Serial.println("Turn Left"); // Wheels move in opposite directions
        leftSpeed-=1;
        rightSpeed-=1; 
        break;
       
        case 50135805:  // Replace this code with the one from your remote!
        Serial.println("Turn Right");  // Wheels move in opposite directions
        leftSpeed+=1;
        rightSpeed+=1;
        break;
       
        case 50139885:  // Replace this code with the one from your remote!
        Serial.println("TURBO!!");  // need to move left servo to go right
        leftSpeed=leftSpeed-50;
        rightSpeed=rightSpeed+50;
        break;

      }
     
     if(DEBUG){
      Serial.println(keyCode);
      showReceivedData();
      Serial.print(leftSpeed);
      Serial.print(", ");
      Serial.println(rightSpeed);
     }
     
    }
    irrecv.resume(); // Receive the next value
  }

  updateMotors();
  delay(10);
}

void showReceivedData()
{
  if (results.decode_type == UNKNOWN)
  {
    Serial.println("-Could not decode message");
  }
  else
  {
    if (results.decode_type == NEC) {
      Serial.print("- decoded NEC: ");
    }
    else if (results.decode_type == SONY) {
      Serial.print("- decoded SONY: ");
    }
    else if (results.decode_type == RC5) {
      Serial.print("- decoded RC5: ");
    }
    else if (results.decode_type == RC6) {
      Serial.print("- decoded RC6: ");
    }
    Serial.print("Value = ");
    Serial.println( results.value, DEC);
  }
}

void updateMotors(){
  leftServo.write(leftSpeed);
  rightServo.write(rightSpeed);
}

PaulS

Thank you, here's the whole code.
When I compile that, I get:
Quote
Binary sketch size: 6,886 bytes (of a 30,720 byte maximum)

roberto03


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy