Cant compile this code

#include "I2Cdev.h"

#include

#include

#include

#include "MPU6050_6Axis_MotionApps20.h"

#define d_speed 1.5 #define d_dir 3

#define IN1 11 #define IN2 10 #define IN3 9 #define IN4 3

char content = 'P'; int MotorAspeed, MotorBspeed; float MOTORSLACK_A = 40; // Compensate for motor slack range (low PWM values which result in no motor engagement) float MOTORSLACK_B = 40; #define BALANCE_PID_MIN -255 // Define PID limits to match PWM max in reverse and foward #define BALANCE_PID_MAX 255

MPU6050 mpu;

const int rxpin = 6; //Bluetooth serial stuff const int txpin = 5; SoftwareSerial blue(rxpin, txpin);

//Ultrasonic ultrasonic(A0, A1); //int distance;

// MPU control/status vars bool dmpReady = false; // set true if DMP init was successful uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU uint8_t devStatus; // return status after each device operation (0 = success, !0 = error) uint16_t packetSize; // expected DMP packet size (default is 42 bytes) uint16_t fifoCount; // count of all bytes currently in FIFO uint8_t fifoBuffer[64]; // FIFO storage buffer

// orientation/motion vars Quaternion q; // [w, x, y, z] quaternion container VectorFloat gravity; // [x, y, z] gravity vector float ypr[3]; // [yaw, pitch, roll] yaw/pitch/roll container and gravity vector

/*********Tune these 4 values for your BOT*********/ double setpoint; //set the value when the bot is perpendicular to ground using serial monitor. double originalSetpoint; //Read the project documentation on circuitdigest.com to learn how to set these values #define Kp 10 //Set this first #define Kd 0.6 //Set this secound #define Ki 160 //Finally set this

#define RKp 50 //Set this first #define RKd 4//Set this secound #define RKi 300 //Finally set this /******End of values setting*********/ double ysetpoint; double yoriginalSetpoint; double input, yinput, youtput, output, Buffer[3];

PID pid(&input, &output, &setpoint, Kp, Ki, Kd, DIRECT); PID rot(&yinput, &youtput, &ysetpoint, RKp, RKi, RKd, DIRECT);

volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high void dmpDataReady() { mpuInterrupt = true; }

void setup() { Serial.begin(115200); blue.begin(9600); blue.setTimeout(10); init_imu(); //initialiser le MPU6050 initmot(); //initialiser les moteurs originalSetpoint = 176; //consigne yoriginalSetpoint = 0.1; setpoint = originalSetpoint ; ysetpoint = yoriginalSetpoint ; }

void loop() { getvalues(); Bt_control(); printval(); }

void init_imu() { // initialize device Serial.println(F("Initializing I2C devices...")); Wire.begin(); TWBR = 24; mpu.initialize();

// verify connection Serial.println(F("Testing device connections...")); Serial.println(mpu.testConnection() ? F("MPU6050 connection successful") : F("MPU6050 connection failed"));

// load and configure the DMP devStatus = mpu.dmpInitialize();

// supply your own gyro offsets here, scaled for min sensitivity mpu.setXGyroOffset(220); mpu.setYGyroOffset(76); mpu.setZGyroOffset(-85); mpu.setZAccelOffset(1688);

// make sure it worked (returns 0 if so) if (devStatus == 0) { // turn on the DMP, now that it's ready Serial.println(F("Enabling DMP...")); mpu.setDMPEnabled(true);

// enable Arduino interrupt detection Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)...")); attachInterrupt(0, dmpDataReady, RISING); mpuIntStatus = mpu.getIntStatus();

// set our DMP Ready flag so the main loop() function knows it's okay to use it Serial.println(F("DMP ready! Waiting for first interrupt...")); dmpReady = true;

// get expected DMP packet size for later comparison packetSize = mpu.dmpGetFIFOPacketSize();

//setup PID pid.SetMode(AUTOMATIC); pid.SetSampleTime(10); pid.SetOutputLimits(-255, 255); rot.SetMode(AUTOMATIC); rot.SetSampleTime(10); rot.SetOutputLimits(-20, 20); } else { // ERROR! // 1 = initial memory load failed // 2 = DMP configuration updates failed // (if it's going to break, usually the code will be 1) Serial.print(F("DMP Initialization failed (code ")); Serial.print(devStatus); Serial.println(F(")")); } }

void getvalues() { // if programming failed, don't try to do anything

if (!dmpReady) return;

// wait for MPU interrupt or extra packet(s) available while (!mpuInterrupt && fifoCount < packetSize) { new_pid(); } // reset interrupt flag and get INT_STATUS byte mpuInterrupt = false; mpuIntStatus = mpu.getIntStatus();

// get current FIFO count fifoCount = mpu.getFIFOCount();

// check for overflow (this should never happen unless our code is too inefficient) if ((mpuIntStatus & 0x10) || fifoCount == 1024) { // reset so we can continue cleanly mpu.resetFIFO(); Serial.println(F("FIFO overflow!"));

// otherwise, check for DMP data ready interrupt (this should happen frequently) } else if (mpuIntStatus & 0x02) { // wait for correct available data length, should be a VERY short wait while (fifoCount < packetSize) fifoCount = mpu.getFIFOCount();

// read a packet from FIFO mpu.getFIFOBytes(fifoBuffer, packetSize);

// track FIFO count here in case there is > 1 packet available // (this lets us immediately read more without waiting for an interrupt) fifoCount -= packetSize;

mpu.dmpGetQuaternion(&q, fifoBuffer); //get value for q mpu.dmpGetGravity(&gravity, &q); //get value for gravity mpu.dmpGetYawPitchRoll(ypr, &q, &gravity); //get value for ypr

input = ypr[1] * 180 / M_PI + 180; yinput = ypr[0] * 180 / M_PI; } }

void new_pid() { //Compute error pid.Compute(); rot.Compute(); // Convert PID output to motor control MotorAspeed = compensate_slack(youtput, output, 1); MotorBspeed = compensate_slack(youtput, output, 0); motorspeed(MotorAspeed, MotorBspeed); //change speed } //Fast digitalWrite is implemented

void Bt_control() { if (blue.available()) { content = blue.read(); if (content == 'F') setpoint = originalSetpoint - d_speed;//Serial.println(setpoint);} //forward else if (content == 'B') setpoint = originalSetpoint + d_speed;//Serial.println(setpoint);} //backward else if (content == 'L') ysetpoint = constrain((ysetpoint + yoriginalSetpoint - d_dir), -180, 180); //Serial.println(ysetpoint);} //left else if (content == 'R') ysetpoint = constrain(ysetpoint + yoriginalSetpoint + d_dir, -180, 180); //Serial.println(ysetpoint);} //right else if (content == 'S') { setpoint = originalSetpoint; } } else content = 'P'; }

void initmot() { //Initialise the Motor outpu pins pinMode (IN4, OUTPUT); pinMode (IN3, OUTPUT); pinMode (IN2, OUTPUT); pinMode (IN1, OUTPUT);

//By default turn off both the motor analogWrite(IN4, LOW); analogWrite(IN3, LOW); analogWrite(IN2, LOW); analogWrite(IN1, LOW); }

double compensate_slack(double yOutput, double Output, bool A) { // Compensate for DC motor non-linear "dead" zone around 0 where small values don't result in movement //yOutput is for left,right control if (A) { if (Output >= 0) Output = Output + MOTORSLACK_A - yOutput; if (Output < 0) Output = Output - MOTORSLACK_A - yOutput; } else { if (Output >= 0) Output = Output + MOTORSLACK_B + yOutput; if (Output < 0) Output = Output - MOTORSLACK_B + yOutput; } Output = constrain(Output, BALANCE_PID_MIN, BALANCE_PID_MAX); return Output; }

void motorspeed(int MotorAspeed, int MotorBspeed) {

// Motor A control if (MotorAspeed >= 0) { analogWrite(IN1, abs(MotorAspeed)); digitalWrite(IN2, LOW); } else { digitalWrite(IN1, LOW); analogWrite(IN2, abs(MotorAspeed)); }

// Motor B control if (MotorBspeed >= 0) { analogWrite(IN3, abs(MotorBspeed)); digitalWrite(IN4, LOW); } else { digitalWrite(IN3, LOW); analogWrite(IN4, abs(MotorBspeed)); } } void printval() { Serial.print(yinput); Serial.print("\t"); Serial.print(yoriginalSetpoint); Serial.print("\t"); Serial.print(ysetpoint); Serial.print("\t"); Serial.print(youtput); Serial.print("\t"); Serial.print("\t"); Serial.print(input); Serial.print("\t"); Serial.print(originalSetpoint); Serial.print("\t"); Serial.print(setpoint); Serial.print("\t"); Serial.print(output); Serial.print("\t"); Serial.print("\t"); Serial.print(MotorAspeed); Serial.print("\t"); Serial.print(MotorBspeed); Serial.print("\t"); Serial.print(content); Serial.println("\t"); }

Hey welcome to the community.

Where did you get this code? What did it say there about how to build the project using it?

Post a link.

You could also post your the code in code tags, use the </> button in the post composition window button bar.

a7

You are making it very difficult to help you. That code is almost impossible to follow. I am not even going to try.

Multiple statements per line make the code very hard to read and follow. The compiler cannot tell what is comment and what is code. Fix that.

Read the forum guidelines to see how to properly post code and some information on how to get the most from this forum.

The lack of indenting makes the code very hard to read and follow. Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

If you are getting errors please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.

Cant compile this code

it's not just the lack of formating, but that much of the code has been concatenated behind comments, "//".

why are there empty includes?

it's hard to imagine that this is the original code

I backtracked the code to the usual source of garbage: Instructables

The current mess seems to have been caused by a chain of sloppiness.

It looks like the author of the instructables author did something unspeakable to the code like copying it from the HTML source of some other website. So it was already corrupted.

Then @jamiejig didn't put the code in a code block. These lines were originally #include directives for files wrapped in angle brackets. The forum supports formatting posts using the Markdown markup language, and Markdown includes a safe subset of HTML.

#include directives that use the angle bracket syntax happen to look a lot like unsupported HTML tags. These tags are generally discarded by the the Markdown parser. So this post source:

#include <vector>

is rendered like this:

#include

It does manage to differentiate the ones where the header file name has an extension, so this post source:

#include <vector.h>

is rendered like this:

#include <vector.h>

The Instructables corruption happens to break even that in some way. For example, this post source:

<p>#include "I2Cdev.h"</p><p>#include <Wire.h></p>

is rendered like this:

#include "I2Cdev.h"

#include


Yet another of the many reasons why code should always be posted in the correct way:

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966#use-code-tags

I tried to fix that code (for practice) and gave up because there were some lines that did not make sense. They looked like variable definitions but with non-existent types. With that include the some of those types now make sense. With all the multi line code mixed in with comments it is still too much work.

that hits the bull's eye :index_pointing_at_the_viewer: :laughing: about what "instructable is:

frustratable dis-struction

best regards Stefan

1 Like

thanks for the effort guys but this is above me at the moment

Well qoogling finds a lot of DIY balancing bots.
This one seems o explain quite a lot of details
and has a button to copy the code just by clicking the button

I haven't analysed if you can use the same components.
If you are just about starting with programming cerating a line-follower-bot is not that impressive as a balancing bot but much more forgiving for bugs and faults.

best regards Stefan

this coda doesn't work also copied errors so i will put them here as i have no idea lol Arduino: 1.8.19 (Windows 10), TD: 1.56, Board: "Arduino Uno"

In file included from C:\Users\jamie\AppData\Local\Temp\arduino_modified_sketch_195378\sketch_mar06b.ino:15:0:

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:278:32: error: no 'uint8_t MPU6050::dmpInitialize()' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpInitialize() {

                            ^

In file included from C:\Users\jamie\AppData\Local\Temp\arduino_modified_sketch_195378\sketch_mar06b.ino:15:0:

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:387:34: error: no 'bool MPU6050::dmpPacketAvailable()' member function declared in class 'MPU6050'

bool MPU6050::dmpPacketAvailable() {

                              ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:414:66: error: no 'uint8_t MPU6050::dmpGetAccel(int32_t*, const uint8_t*)' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpGetAccel(int32_t data, const uint8_t packet) {

                                                              ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:422:66: error: no 'uint8_t MPU6050::dmpGetAccel(int16_t*, const uint8_t*)' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpGetAccel(int16_t data, const uint8_t packet) {

                                                              ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:430:67: error: no 'uint8_t MPU6050::dmpGetAccel(VectorInt16*, const uint8_t*)' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpGetAccel(VectorInt16 v, const uint8_t packet) {

                                                               ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:438:71: error: no 'uint8_t MPU6050::dmpGetQuaternion(int32_t*, const uint8_t*)' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpGetQuaternion(int32_t data, const uint8_t packet) {

                                                                   ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:447:71: error: no 'uint8_t MPU6050::dmpGetQuaternion(int16_t*, const uint8_t*)' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpGetQuaternion(int16_t data, const uint8_t packet) {

                                                                   ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:456:71: error: no 'uint8_t MPU6050::dmpGetQuaternion(Quaternion*, const uint8_t*)' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpGetQuaternion(Quaternion q, const uint8_t packet) {

                                                                   ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:471:65: error: no 'uint8_t MPU6050::dmpGetGyro(int32_t*, const uint8_t*)' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpGetGyro(int32_t data, const uint8_t packet) {

                                                             ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:479:65: error: no 'uint8_t MPU6050::dmpGetGyro(int16_t*, const uint8_t*)' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpGetGyro(int16_t data, const uint8_t packet) {

                                                             ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:487:66: error: no 'uint8_t MPU6050::dmpGetGyro(VectorInt16*, const uint8_t*)' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpGetGyro(VectorInt16 v, const uint8_t packet) {

                                                              ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:497:91: error: no 'uint8_t MPU6050::dmpGetLinearAccel(VectorInt16*, VectorInt16*, VectorFloat*)' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpGetLinearAccel(VectorInt16 *v, VectorInt16 *vRaw, VectorFloat *gravity) {

                                                                                       ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:505:92: error: no 'uint8_t MPU6050::dmpGetLinearAccelInWorld(VectorInt16*, VectorInt16*, Quaternion*)' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpGetLinearAccelInWorld(VectorInt16 *v, VectorInt16 *vReal, Quaternion *q) {

                                                                                        ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:517:68: error: no 'uint8_t MPU6050::dmpGetGravity(int16_t*, const uint8_t*)' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpGetGravity(int16_t data, const uint8_t packet) {

                                                                ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:528:61: error: no 'uint8_t MPU6050::dmpGetGravity(VectorFloat*, Quaternion*)' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpGetGravity(VectorFloat *v, Quaternion *q) {

                                                         ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:539:56: error: no 'uint8_t MPU6050::dmpGetEuler(float*, Quaternion*)' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpGetEuler(float *data, Quaternion *q) {

                                                    ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:557:85: error: no 'uint8_t MPU6050::dmpGetYawPitchRoll(float*, Quaternion*, VectorFloat*)' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpGetYawPitchRoll(float *data, Quaternion *q, VectorFloat *gravity) {

                                                                                 ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:578:67: error: no 'uint8_t MPU6050::dmpProcessFIFOPacket(const unsigned char*)' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpProcessFIFOPacket(const unsigned char *dmpData) {

                                                               ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:588:84: error: no 'uint8_t MPU6050::dmpReadAndProcessFIFOPacket(uint8_t, uint8_t*)' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpReadAndProcessFIFOPacket(uint8_t numPackets, uint8_t *processed) {

                                                                                ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:613:40: error: no 'uint16_t MPU6050::dmpGetFIFOPacketSize()' member function declared in class 'MPU6050'

uint16_t MPU6050::dmpGetFIFOPacketSize() {

                                    ^

C:\Users\jamie\Documents\Arduino\libraries\MPU6050\src/MPU6050_6Axis_MotionApps20.h:619:55: error: no 'uint8_t MPU6050::dmpGetCurrentFIFOPacket(uint8_t*)' member function declared in class 'MPU6050'

uint8_t MPU6050::dmpGetCurrentFIFOPacket(uint8_t *data) { // overflow proof

                                                   ^

C:\Users\jamie\AppData\Local\Temp\arduino_modified_sketch_195378\sketch_mar06b.ino: In function 'void setup()':

sketch_mar06b:61:19: error: 'class MPU6050' has no member named 'dmpInitialize'; did you mean 'initialize'?

devStatus = mpu.dmpInitialize();

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

               initialize

sketch_mar06b:87:22: error: 'class MPU6050' has no member named 'dmpGetFIFOPacketSize'

 packetSize = mpu.dmpGetFIFOPacketSize();

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

C:\Users\jamie\AppData\Local\Temp\arduino_modified_sketch_195378\sketch_mar06b.ino: In function 'void loop()':

sketch_mar06b:172:9: error: 'class MPU6050' has no member named 'dmpGetQuaternion'

 mpu.dmpGetQuaternion(&q, fifoBuffer); //get value for q

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

sketch_mar06b:173:9: error: 'class MPU6050' has no member named 'dmpGetGravity'

 mpu.dmpGetGravity(&gravity, &q); //get value for gravity

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

sketch_mar06b:174:9: error: 'class MPU6050' has no member named 'dmpGetYawPitchRoll'

 mpu.dmpGetYawPitchRoll(ypr, &q, &gravity); //get value for ypr

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

Multiple libraries were found for "MPU6050.h"

Used: C:\Users\jamie\Documents\Arduino\libraries\MPU6050

Not used: C:\Users\jamie\Documents\Arduino\libraries\MPU6050-master

exit status 1

'class MPU6050' has no member named 'dmpInitialize'; did you mean 'initialize'?

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

The next step you sould leran is how to create

code-sections.

Look at the pictures in this thread to lean how to re-edit a posting and how to post error-messages as a code-section

You have to install the not yet installed libraries.

best regards Stefan

i did include the extra libraries adn it seamed to accept them

what pictures

the code names the sources which exact libraries to install from Github
additionally tips how to improve your posting style

found them sorry

i did not include extensions as it doesn't work anyway so is this post any better Preformatted text Arduino: 1.8.19 (Windows 10), TD: 1.56, Board: "Arduino Uno"

sketch_mar06b:1:4: error: stray '#' in program

#include "I2Cdev.h"

#include

#include

#include

#include "MPU6050_6Axis_MotionApps20.h"

#define d_speed 1.5

^

sketch_mar06b:1:30: error: stray '#' in program

#include "I2Cdev.h"

#include

#include

#include

#include "MPU6050_6Axis_MotionApps20.h"

#define d_speed 1.5

                          ^

sketch_mar06b:1:71: error: stray '#' in program

#include "I2Cdev.h"

#include

#include

#include

#include "MPU6050_6Axis_MotionApps20.h"

#define d_speed 1.5

                                                                   ^

sketch_mar06b:1:97: error: stray '#' in program

#include "I2Cdev.h"

#include

#include

#include

#include "MPU6050_6Axis_MotionApps20.h"

#define d_speed 1.5

                                                                                             ^

sketch_mar06b:1:131: error: stray '#' in program

#include "I2Cdev.h"

#include

#include

#include

#include "MPU6050_6Axis_MotionApps20.h"

#define d_speed 1.5

                                                                                                                               ^

sketch_mar06b:1:337: error: stray '#' in program

#include "I2Cdev.h"

#include

#include

#include

#include "MPU6050_6Axis_MotionApps20.h"

#define d_speed 1.5

                                                                                                                                                                                                                                                                                                                                             ^

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

sketch_mar06b:2:28: error: stray '#' in program

#define d_dir 3

#define IN1 11

                        ^

C:\Users\jamie\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Arduino.h:95:35: note: in definition of macro 'constrain'

#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))

                               ^~~

C:\Users\jamie\AppData\Local\Temp\arduino_modified_sketch_701459\sketch_mar06b.ino:136:60: note: in expansion of macro 'd_dir'

 ysetpoint = constrain((ysetpoint + yoriginalSetpoint - d_dir), -180, 180); //Serial.println(ysetpoint);}      //left

                                                        ^~~~~

sketch_mar06b:2:28: error: stray '#' in program

#define d_dir 3

#define IN1 11

                        ^

C:\Users\jamie\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Arduino.h:95:54: note: in definition of macro 'constrain'

#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))

                                                  ^~~

C:\Users\jamie\AppData\Local\Temp\arduino_modified_sketch_701459\sketch_mar06b.ino:136:60: note: in expansion of macro 'd_dir'

 ysetpoint = constrain((ysetpoint + yoriginalSetpoint - d_dir), -180, 180); //Serial.println(ysetpoint);}      //left

                                                        ^~~~~

sketch_mar06b:2:28: error: stray '#' in program

#define d_dir 3

#define IN1 11

                        ^

C:\Users\jamie\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Arduino.h:95:74: note: in definition of macro 'constrain'

#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))

                                                                      ^~~

C:\Users\jamie\AppData\Local\Temp\arduino_modified_sketch_701459\sketch_mar06b.ino:136:60: note: in expansion of macro 'd_dir'

 ysetpoint = constrain((ysetpoint + yoriginalSetpoint - d_dir), -180, 180); //Serial.println(ysetpoint);}      //left

                                                        ^~~~~

sketch_mar06b:2:28: error: stray '#' in program

#define d_dir 3

#define IN1 11

                        ^

C:\Users\jamie\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Arduino.h:95:35: note: in definition of macro 'constrain'

#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))

                               ^~~

C:\Users\jamie\AppData\Local\Temp\arduino_modified_sketch_701459\sketch_mar06b.ino:138:59: note: in expansion of macro 'd_dir'

 ysetpoint = constrain(ysetpoint + yoriginalSetpoint + d_dir, -180, 180); //Serial.println(ysetpoint);}        //right

                                                       ^~~~~

sketch_mar06b:2:28: error: stray '#' in program

#define d_dir 3

#define IN1 11

                        ^

C:\Users\jamie\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Arduino.h:95:54: note: in definition of macro 'constrain'

#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))

                                                  ^~~

C:\Users\jamie\AppData\Local\Temp\arduino_modified_sketch_701459\sketch_mar06b.ino:138:59: note: in expansion of macro 'd_dir'

 ysetpoint = constrain(ysetpoint + yoriginalSetpoint + d_dir, -180, 180); //Serial.println(ysetpoint);}        //right

                                                       ^~~~~

sketch_mar06b:2:28: error: stray '#' in program

#define d_dir 3

#define IN1 11

                        ^

C:\Users\jamie\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.5\cores\arduino/Arduino.h:95:74: note: in definition of macro 'constrain'

#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))

                                                                      ^~~

C:\Users\jamie\AppData\Local\Temp\arduino_modified_sketch_701459\sketch_mar06b.ino:138:59: note: in expansion of macro 'd_dir'

 ysetpoint = constrain(ysetpoint + yoriginalSetpoint + d_dir, -180, 180); //Serial.println(ysetpoint);}        //right

                                                       ^~~~~

sketch_mar06b:1:1: error: expected unqualified-id before '<' token

#include "I2Cdev.h"

#include

#include

#include

#include "MPU6050_6Axis_MotionApps20.h"

#define d_speed 1.5

^

sketch_mar06b:12:1: error: 'SoftwareSerial' does not name a type; did you mean 'HardwareSerial'?

SoftwareSerial blue(rxpin, txpin); < / p >

//Ultrasonic ultrasonic(A0, A1);

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

HardwareSerial

sketch_mar06b:12:36: error: expected unqualified-id before '<' token

SoftwareSerial blue(rxpin, txpin); < / p >

//Ultrasonic ultrasonic(A0, A1);

                                ^

sketch_mar06b:20:1: error: 'Quaternion' does not name a type; did you mean 'union'?

Quaternion q; // [w, x, y, z] quaternion container

^~~~~~~~~~

union

sketch_mar06b:21:1: error: 'VectorFloat' does not name a type

VectorFloat gravity; // [x, y, z] gravity vector

^~~~~~~~~~~

sketch_mar06b:34:51: error: expected unqualified-id before '<' token

double input, yinput, youtput, output, Buffer[3]; < / p >

PID pid(&input, &output, &setpoint, Kp, Ki, Kd, DIRECT);

                                               ^

sketch_mar06b:35:1: error: 'PID' does not name a type; did you mean 'PIND'?

PID rot(&yinput, &youtput, &ysetpoint, RKp, RKi, RKd, DIRECT); < / p >

volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high

^~~

PIND

sketch_mar06b:35:64: error: expected unqualified-id before '<' token

PID rot(&yinput, &youtput, &ysetpoint, RKp, RKi, RKd, DIRECT); < / p >

volatile bool mpuInterrupt = false; // indicates whether MPU interrupt pin has gone high

                                                            ^

C:\Users\jamie\AppData\Local\Temp\arduino_modified_sketch_701459\sketch_mar06b.ino: In function 'void dmpDataReady()':

sketch_mar06b:38:3: error: 'mpuInterrupt' was not declared in this scope

mpuInterrupt = true;

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

C:\Users\jamie\AppData\Local\Temp\arduino_modified_sketch_701459\sketch_mar06b.ino:38:3: note: suggested alternative: 'noInterrupts'

mpuInterrupt = true;

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

noInterrupts

C:\Users\jamie\AppData\Local\Temp\arduino_modified_sketch_701459\sketch_mar06b.ino: At global scope:

sketch_mar06b:39:3: error: expected unqualified-id before '<' token

} < / p >

void setup() {

^

sketch_mar06b:49:3: error: expected unqualified-id before '<' token

} < / p >

void loop() {

^

sketch_mar06b:53:3: error: expected unqualified-id before '<' token

} < / p >

void init_imu() {

^

sketch_mar06b:93:3: error: expected unqualified-id before '<' token

} < / p >

void getvalues() {

^

sketch_mar06b:119:3: error: expected unqualified-id before '<' token

} < / p >

void new_pid() {

^

sketch_mar06b:129:1: error: expected unqualified-id before 'if'

if (blue.available()) {

^~

sketch_mar06b:143:1: error: expected unqualified-id before 'else'

else content = 'P';

^~~~

sketch_mar06b:144:1: error: expected declaration before '}' token

} < / p >

void initmot() {

^

exit status 1

stray '#' in program

Invalid library found in C:\Users\jamie\Documents\Arduino\libraries\sketch_mar02c: no headers files (.h) found in C:\Users\jamie\Documents\Arduino\libraries\sketch_mar02c

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

SORRY to all thanks for the help every day is a school day

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