Error: macro names must be identifiers #ifdef dobogusinclude

Hi, I'm new to Arduino.
Can I ask someone to help me with this code pls ?

<#include <PS4USB.h>

#include <Wire.h>

#include <Adafruit_MotorShield.h>

#include <Stepper.h>

#ifdef dobogusinclude

#include <spi4teensy3.h>

#endif

#include <SPI.h>

USB Usb;

PS4USB PS4(&Usb);

bool printAngle, printTouch;

uint8_t oldL2Value, oldR2Value, oldLedValue;

Adafruit_MotorShield AFMStop(0x62);

Adafruit_MotorShield AFMSmid(0x61);

Adafruit_MotorShield AFMSbot(0x60);

Adafruit_StepperMotor *M3 = AFMStop.getStepper(1500, 1);

Adafruit_StepperMotor *M6 = AFMStop.getStepper(1800, 2);

Adafruit_StepperMotor *M2 = AFMSmid.getStepper(3250, 1);

Adafruit_StepperMotor *M5 = AFMSmid.getStepper(1800, 2);

Adafruit_StepperMotor *M1 = AFMSbot.getStepper(9000, 1);

Adafruit_StepperMotor *M4 = AFMSbot.getStepper(1800, 2);

void setup() {

Serial.begin(115200);

if (Usb.Init() == -1) {

Serial.print(F("\r\nOSC did not start"));  

while (1); // Halt  

}

Serial.print(F("\r\nPS4 USB Library Started"));

AFMSbot.begin(); // Start the bottom shield

AFMSmid.begin(); // Start the middle shield

AFMStop.begin(); // Start the top shield

// Motor RPM

M1->setSpeed(5);

M2->setSpeed(10);

M3->setSpeed(10);

M4->setSpeed(3);

M5->setSpeed(3);

M6->setSpeed(10);

}

void loop() {

Usb.Task();

if (PS4.connected()) {

if (PS4.getButtonClick(CROSS)) {

  Serial.print(F("\r\nCross"));  

  M1->release();  

  M2->release();  

  M3->release();  

  M4->release();  

  M5->release();  

  M6->release();  

}  

if (PS4.getAnalogButton(L2) || PS4.getAnalogButton(R2)) { // These are the only analog buttons on the PS4 controller

  Serial.print(F("\r\nL2: "));  

  Serial.print(PS4.getAnalogButton(L2));  

  Serial.print(F("\tR2: "));  

  Serial.print(PS4.getAnalogButton(R2));  

}  

if (PS4.getAnalogButton(L2)) { //base left

M1->step(1,BACKWARD,SINGLE);

}

if (PS4.getAnalogButton(R2)) { //base right

M1->step(1,FORWARD,SINGLE);

}

if (PS4.getAnalogHat(LeftHatX) > 137 || PS4.getAnalogHat(LeftHatX) < 117 || PS4.getAnalogHat(LeftHatY) > 137 || PS4.getAnalogHat(LeftHatY) < 117 || PS4.getAnalogHat(RightHatX) > 137 || PS4.getAnalogHat(RightHatX) < 117 || PS4.getAnalogHat(RightHatY) > 137 || PS4.getAnalogHat(RightHatY) < 117) {

  Serial.print(F("\r\nLeftHatX: "));  

  Serial.print(PS4.getAnalogHat(LeftHatX));  

  Serial.print(F("\tLeftHatY: "));  

  Serial.print(PS4.getAnalogHat(LeftHatY));  

  Serial.print(F("\tRightHatX: "));  

  Serial.print(PS4.getAnalogHat(RightHatX));  

  Serial.print(F("\tRightHatY: "));  

  Serial.print(PS4.getAnalogHat(RightHatY));  

}  

if (PS4.getAnalogButton(L2)==true || PS4.getAnalogButton(R2)==true){

M2->release();

M3->release();

M4->release();

M5->release();

M6->release();

}

if (PS4.getAnalogHat(LeftHatX) < 117) { //shoulder up

M2->step(1,FORWARD,SINGLE);

}

if (PS4.getAnalogHat(LeftHatX) > 137) { //shoulder down

M2->step(1,BACKWARD,SINGLE);

}

if (PS4.getAnalogHat(LeftHatY) < 117) { //elbow up

M3->step(1,BACKWARD,SINGLE);

}

if (PS4.getAnalogHat(LeftHatY) > 137) { //elboe down

M3->step(1,FORWARD,SINGLE);

}

if (PS4.getAnalogHat(LeftHatX) < 117==true || PS4.getAnalogHat(LeftHatX) > 137==true || PS4.getAnalogHat(LeftHatY) < 117==true || PS4.getAnalogHat(LeftHatY) > 137==true){

M1->release();

//M3->release();

}/* else if (PS4.getAnalogHat(LeftHatY) < 117==true || PS4.getAnalogHat(LeftHatY) > 137==true){

M1->release();

M2->release();

}*/

if (PS4.getAnalogHat(RightHatX) < 117) { //wrist left

M4->step(1,BACKWARD,DOUBLE);

M5->step(1,BACKWARD,DOUBLE);

}

if (PS4.getAnalogHat(RightHatX) > 137) { //wrsit right

M4->step(1,FORWARD,DOUBLE);

M5->step(1,FORWARD,DOUBLE);

}

if (PS4.getAnalogHat(RightHatY) < 117) { //wrist up

M4->step(1,BACKWARD,DOUBLE);

M5->step(1,FORWARD,DOUBLE);

}

if (PS4.getAnalogHat(RightHatY) > 137) { //wrist down

M4->step(1,FORWARD,DOUBLE);

M5->step(1,BACKWARD,DOUBLE);

}

if (PS4.getAnalogHat(RightHatY) < 117==true || PS4.getAnalogHat(RightHatY) > 137==true || PS4.getAnalogHat(RightHatX) < 117==true || PS4.getAnalogHat(RightHatX) > 137){

M1->release();

M2->release();

M3->release();

M6->release();

}

if (PS4.getButtonClick(L1)) { //wrist open

Serial.print(F("\r\nL1"));

M6->step(600,FORWARD,DOUBLE);

M1->release();

M2->release();

M3->release();

M4->release();

M5->release();

}

if (PS4.getButtonClick(R1)) { //wrsit close

Serial.print(F("\r\nR1"));

M6->step(600,BACKWARD,DOUBLE);

M1->release();

M2->release();

M3->release();

M4->release();

M5->release();

}

//Light set up

if (PS4.getAnalogButton(L2)==255 || PS4.getAnalogButton(R2)==255|| PS4.getAnalogHat(LeftHatX) < 117==true ||

PS4.getAnalogHat(LeftHatX) > 137==true||PS4.getAnalogHat(LeftHatY) < 117==true || PS4.getAnalogHat(LeftHatY) > 137==true||

PS4.getAnalogHat(RightHatX) < 117==true || PS4.getAnalogHat(RightHatX) > 137==true||PS4.getAnalogHat(RightHatY) < 117==true || PS4.getAnalogHat(RightHatY) > 137==true){

PS4.setLed(Red);
} else (PS4.setLed(Blue));
} >

Can I ask you to take a couple of moments and read this: How to get the best out of this forum - Using Arduino / Installation & Troubleshooting - Arduino Forum
and then go back and edit your post to include code tags around your code and also include your entire error message (again with code tags).

That #ifdef statement is fine. Are you defining it somewhere else?

Thanks, I just get this one back from previous group, I am doing the capstone project to build it for robot arm.
So I actually blind in these one

@ttrung1, your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project :wink: See About the Installation & Troubleshooting category.

Please do as requested by @blh64 and add code tags.

I tweaked a few things to get rid of some warnings but this version compiles without error or warning for me:

#include <PS4USB.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include <Stepper.h>

#ifdef dobogusinclude
#include <spi4teensy3.h>
#endif

#include <SPI.h>

USB Usb;
PS4USB PS4(&Usb);
bool printAngle, printTouch;
uint8_t oldL2Value, oldR2Value, oldLedValue;
Adafruit_MotorShield AFMStop(0x62);
Adafruit_MotorShield AFMSmid(0x61);
Adafruit_MotorShield AFMSbot(0x60);
Adafruit_StepperMotor *M3 = AFMStop.getStepper(1500, 1);
Adafruit_StepperMotor *M6 = AFMStop.getStepper(1800, 2);
Adafruit_StepperMotor *M2 = AFMSmid.getStepper(3250, 1);
Adafruit_StepperMotor *M5 = AFMSmid.getStepper(1800, 2);
Adafruit_StepperMotor *M1 = AFMSbot.getStepper(9000, 1);
Adafruit_StepperMotor *M4 = AFMSbot.getStepper(1800, 2);

void setup()
{
  Serial.begin(115200);
  if (Usb.Init() == -1)
  {
    Serial.print(F("\r\nOSC did not start"));
    while (1); // Halt
  }
  Serial.print(F("\r\nPS4 USB Library Started"));
  AFMSbot.begin(); // Start the bottom shield
  AFMSmid.begin(); // Start the middle shield
  AFMStop.begin(); // Start the top shield
  // Motor RPM
  M1->setSpeed(5);
  M2->setSpeed(10);
  M3->setSpeed(10);
  M4->setSpeed(3);
  M5->setSpeed(3);
  M6->setSpeed(10);
}

void loop()
{
  Usb.Task();
  if (PS4.connected())
  {
    if (PS4.getButtonClick(CROSS))
    {
      Serial.print(F("\r\nCross"));
      M1->release();
      M2->release();
      M3->release();
      M4->release();
      M5->release();
      M6->release();
    }

    // These are the only analog buttons on the PS4 controller
    if (PS4.getAnalogButton(L2) || PS4.getAnalogButton(R2))
    {
      Serial.print(F("\r\nL2: "));
      Serial.print(PS4.getAnalogButton(L2));
      Serial.print(F("\tR2: "));
      Serial.print(PS4.getAnalogButton(R2));
    }

    if (PS4.getAnalogButton(L2))   //base left
    {
      M1->step(1, BACKWARD, SINGLE);
    }

    if (PS4.getAnalogButton(R2))   //base right
    {
      M1->step(1, FORWARD, SINGLE);
    }

    if (PS4.getAnalogHat(LeftHatX) > 137 || PS4.getAnalogHat(LeftHatX) < 117 ||
        PS4.getAnalogHat(LeftHatY) > 137 || PS4.getAnalogHat(LeftHatY) < 117 ||
        PS4.getAnalogHat(RightHatX) > 137 || PS4.getAnalogHat(RightHatX) < 117 ||
        PS4.getAnalogHat(RightHatY) > 137 || PS4.getAnalogHat(RightHatY) < 117)
    {
      Serial.print(F("\r\nLeftHatX: "));
      Serial.print(PS4.getAnalogHat(LeftHatX));
      Serial.print(F("\tLeftHatY: "));
      Serial.print(PS4.getAnalogHat(LeftHatY));
      Serial.print(F("\tRightHatX: "));
      Serial.print(PS4.getAnalogHat(RightHatX));
      Serial.print(F("\tRightHatY: "));
      Serial.print(PS4.getAnalogHat(RightHatY));
    }

    if (PS4.getAnalogButton(L2) || PS4.getAnalogButton(R2))
    {
      M2->release();
      M3->release();
      M4->release();
      M5->release();
      M6->release();
    }

    if (PS4.getAnalogHat(LeftHatX) < 117)   //shoulder up
    {
      M2->step(1, FORWARD, SINGLE);
    }

    if (PS4.getAnalogHat(LeftHatX) > 137)   //shoulder down
    {
      M2->step(1, BACKWARD, SINGLE);
    }

    if (PS4.getAnalogHat(LeftHatY) < 117)   //elbow up
    {
      M3->step(1, BACKWARD, SINGLE);
    }

    if (PS4.getAnalogHat(LeftHatY) > 137)   //elboe down
    {
      M3->step(1, FORWARD, SINGLE);
    }

    if (PS4.getAnalogHat(LeftHatX) < 117 || PS4.getAnalogHat(LeftHatX) > 137
        || PS4.getAnalogHat(LeftHatY) < 117 || PS4.getAnalogHat(LeftHatY) > 137)
    {
      M1->release();
      //M3->release();
    }
    //    else if (PS4.getAnalogHat(LeftHatY) < 117 || PS4.getAnalogHat(LeftHatY) > 137)
    //    {
    //      M1->release();
    //      M2->release();
    //    }


    if (PS4.getAnalogHat(RightHatX) < 117)   //wrist left
    {
      M4->step(1, BACKWARD, DOUBLE);
      M5->step(1, BACKWARD, DOUBLE);
    }

    if (PS4.getAnalogHat(RightHatX) > 137)   //wrsit right
    {
      M4->step(1, FORWARD, DOUBLE);
      M5->step(1, FORWARD, DOUBLE);
    }

    if (PS4.getAnalogHat(RightHatY) < 117)   //wrist up
    {
      M4->step(1, BACKWARD, DOUBLE);
      M5->step(1, FORWARD, DOUBLE);
    }

    if (PS4.getAnalogHat(RightHatY) > 137)   //wrist down
    {
      M4->step(1, FORWARD, DOUBLE);
      M5->step(1, BACKWARD, DOUBLE);
    }

    if (PS4.getAnalogHat(RightHatY) < 117 || PS4.getAnalogHat(RightHatY) > 137 ||
        PS4.getAnalogHat(RightHatX) < 117 || PS4.getAnalogHat(RightHatX) > 137)
    {
      M1->release();
      M2->release();
      M3->release();
      M6->release();
    }

    if (PS4.getButtonClick(L1))   //wrist open
    {
      Serial.print(F("\r\nL1"));
      M6->step(600, FORWARD, DOUBLE);
      M1->release();
      M2->release();
      M3->release();
      M4->release();
      M5->release();
    }

    if (PS4.getButtonClick(R1))   //wrsit close
    {
      Serial.print(F("\r\nR1"));
      M6->step(600, BACKWARD, DOUBLE);
      M1->release();
      M2->release();
      M3->release();
      M4->release();
      M5->release();
    }

    //Light set up
    if (PS4.getAnalogButton(L2) == 255 || PS4.getAnalogButton(R2) == 255 ||
        PS4.getAnalogHat(LeftHatX) < 117 || PS4.getAnalogHat(LeftHatX) > 137 ||
        PS4.getAnalogHat(LeftHatY) < 117 || PS4.getAnalogHat(LeftHatY) > 137 ||
        PS4.getAnalogHat(RightHatX) < 117 || PS4.getAnalogHat(RightHatX) > 137 ||
        PS4.getAnalogHat(RightHatY) < 117 || PS4.getAnalogHat(RightHatY) > 137)
    {
      PS4.setLed(Red);
    }
    else
    {
      PS4.setLed(Blue);
    }
  }
}
1 Like

Thanks a lot