Skip to main content
Added information from the comments
Source Link
sa_leinad
  • 3.2k
  • 2
  • 24
  • 53

I am having trouble with this code:

#include <Wire.h>
#include <MPU6050.h>

MPU6050 mpu;

// Timers
unsigned long timer = 0;
float timeStep = 0.01;

// Pitch, Roll and Yaw values
float pitch = 0;
float roll = 0;
float yaw = 0;

int button_pin=5;
int button_state;
void setup() 
{
  Serial.begin(115200);

  // Initialize MPU605  
  while(mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
  {
    Serial.println("Could not find a valid MPU6050 sensor, check wiring!");
    delay(500);
  }
  
  // Calibrate gyroscope. The calibration must be at rest.
  // If you don't want calibrate, comment this line.
  mpu.calibrateGyro();

  // Set threshold sensivty. Default 3.
  // If you don't want use threshold, comment this line or set 0.
  mpu.setThreshold(3);

  pinmode(button_pin,INPUT)
}

void loop()
{
 
  int button_state=digitalRead(button_pin)

  timer = millis();

  // Read normalized values
  Vector norm = mpu.readNormalizeGyro();

  // Calculate Pitch, Roll and Yaw
  pitch = pitch + norm.YAxis * timeStep;
  roll = roll + norm.XAxis * timeStep;
  yaw = yaw + norm.ZAxis * timeStep;

  // Output raw
  Serial.print(" Pitch = ");
  Serial.print(pitch);
  Serial.print(" Roll = ");
  Serial.print(roll);  
  Serial.print(" Yaw = ");
  Serial.println(yaw);

  // Wait to full timeStep period
  delay((timeStep*1000) - (millis() - timer));
}
 
 

But when I add this code at the end I keep getting an error:

If (pitch <=90 && pitch => 15 && button_state =(HIGH))
{
}

I keep getting this error:

error: lvalue required as left operand of assignment

I know the issue is about the pitch part of the if. I just need to know how to fix it.

I am having trouble with this code:

#include <Wire.h>
#include <MPU6050.h>

MPU6050 mpu;

// Timers
unsigned long timer = 0;
float timeStep = 0.01;

// Pitch, Roll and Yaw values
float pitch = 0;
float roll = 0;
float yaw = 0;

int button_pin=5;
int button_state;
void setup() 
{
  Serial.begin(115200);

  // Initialize MPU605  
  while(mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
  {
    Serial.println("Could not find a valid MPU6050 sensor, check wiring!");
    delay(500);
  }
  
  // Calibrate gyroscope. The calibration must be at rest.
  // If you don't want calibrate, comment this line.
  mpu.calibrateGyro();

  // Set threshold sensivty. Default 3.
  // If you don't want use threshold, comment this line or set 0.
  mpu.setThreshold(3);

  pinmode(button_pin,INPUT)
}

void loop()
{
 
  int button_state=digitalRead(button_pin)

  timer = millis();

  // Read normalized values
  Vector norm = mpu.readNormalizeGyro();

  // Calculate Pitch, Roll and Yaw
  pitch = pitch + norm.YAxis * timeStep;
  roll = roll + norm.XAxis * timeStep;
  yaw = yaw + norm.ZAxis * timeStep;

  // Output raw
  Serial.print(" Pitch = ");
  Serial.print(pitch);
  Serial.print(" Roll = ");
  Serial.print(roll);  
  Serial.print(" Yaw = ");
  Serial.println(yaw);

  // Wait to full timeStep period
  delay((timeStep*1000) - (millis() - timer));
}
 
 

But when I add this code at the end I keep getting an error:

If (pitch <=90 && pitch => 15 && button_state =(HIGH))
{
}

I know the issue is about the pitch part of the if. I just need to know how to fix it.

I am having trouble with this code:

#include <Wire.h>
#include <MPU6050.h>

MPU6050 mpu;

// Timers
unsigned long timer = 0;
float timeStep = 0.01;

// Pitch, Roll and Yaw values
float pitch = 0;
float roll = 0;
float yaw = 0;

int button_pin=5;
int button_state;
void setup() 
{
  Serial.begin(115200);

  // Initialize MPU605  
  while(mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
  {
    Serial.println("Could not find a valid MPU6050 sensor, check wiring!");
    delay(500);
  }
  
  // Calibrate gyroscope. The calibration must be at rest.
  // If you don't want calibrate, comment this line.
  mpu.calibrateGyro();

  // Set threshold sensivty. Default 3.
  // If you don't want use threshold, comment this line or set 0.
  mpu.setThreshold(3);

  pinmode(button_pin,INPUT)
}

void loop()
{
  int button_state=digitalRead(button_pin)

  timer = millis();

  // Read normalized values
  Vector norm = mpu.readNormalizeGyro();

  // Calculate Pitch, Roll and Yaw
  pitch = pitch + norm.YAxis * timeStep;
  roll = roll + norm.XAxis * timeStep;
  yaw = yaw + norm.ZAxis * timeStep;

  // Output raw
  Serial.print(" Pitch = ");
  Serial.print(pitch);
  Serial.print(" Roll = ");
  Serial.print(roll);  
  Serial.print(" Yaw = ");
  Serial.println(yaw);

  // Wait to full timeStep period
  delay((timeStep*1000) - (millis() - timer));
}
 

But when I add this code at the end:

If (pitch <=90 && pitch => 15 && button_state =(HIGH))
{
}

I keep getting this error:

error: lvalue required as left operand of assignment

I know the issue is about the pitch part of the if. I just need to know how to fix it.

Formatted code and added tag.
Source Link
sa_leinad
  • 3.2k
  • 2
  • 24
  • 53

#include <Wire.h> #include <MPU6050.h>

MPU6050 mpu;

// Timers unsigned long timer = 0; float timeStep = 0.01;

// Pitch, Roll and Yaw values float pitch = 0; float roll = 0; float yaw = 0;

int button_pin=5; int button_state; void setup() { Serial.begin(115200);

// Initialize MPU605
while(mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G)) { Serial.println("Could not find a valid MPU6050 sensor, check wiring!"); delay(500); }

// Calibrate gyroscope. The calibration must be at rest. // If you don't want calibrate, comment this line. mpu.calibrateGyro();

// Set threshold sensivty. Default 3. // If you don't want use threshold, comment this line or set 0. mpu.setThreshold(3);

pinmode(button_pin,INPUT) }

void loop() {

int button_state=digitalRead(button_pin)

timer = millis();

// Read normalized values Vector norm = mpu.readNormalizeGyro();

// Calculate Pitch, Roll and Yaw pitch = pitch + norm.YAxis * timeStep; roll = roll + norm.XAxis * timeStep; yaw = yaw + norm.ZAxis * timeStep;

// Output raw Serial.print(" Pitch = "); Serial.print(pitch); Serial.print(" Roll = "); Serial.print(roll);
Serial.print(" Yaw = "); Serial.println(yaw);

// Wait to full timeStep period delay((timeStep*1000) - (millis() - timer)); }

#include <Wire.h>
#include <MPU6050.h>

MPU6050 mpu;

// Timers
unsigned long timer = 0;
float timeStep = 0.01;

// Pitch, Roll and Yaw values
float pitch = 0;
float roll = 0;
float yaw = 0;

int button_pin=5;
int button_state;
void setup() 
{
  Serial.begin(115200);

  // Initialize MPU605  
  while(mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
  {
    Serial.println("Could not find a valid MPU6050 sensor, check wiring!");
    delay(500);
  }
  
  // Calibrate gyroscope. The calibration must be at rest.
  // If you don't want calibrate, comment this line.
  mpu.calibrateGyro();

  // Set threshold sensivty. Default 3.
  // If you don't want use threshold, comment this line or set 0.
  mpu.setThreshold(3);

  pinmode(button_pin,INPUT)
}

void loop()
{

  int button_state=digitalRead(button_pin)

  timer = millis();

  // Read normalized values
  Vector norm = mpu.readNormalizeGyro();

  // Calculate Pitch, Roll and Yaw
  pitch = pitch + norm.YAxis * timeStep;
  roll = roll + norm.XAxis * timeStep;
  yaw = yaw + norm.ZAxis * timeStep;

  // Output raw
  Serial.print(" Pitch = ");
  Serial.print(pitch);
  Serial.print(" Roll = ");
  Serial.print(roll);  
  Serial.print(" Yaw = ");
  Serial.println(yaw);

  // Wait to full timeStep period
  delay((timeStep*1000) - (millis() - timer));
}

 
   İf (pitch <=90 && pitch => 15 && button_state =(HIGH)){

}

If (pitch <=90 && pitch => 15 && button_state =(HIGH))
{
}

#include <Wire.h> #include <MPU6050.h>

MPU6050 mpu;

// Timers unsigned long timer = 0; float timeStep = 0.01;

// Pitch, Roll and Yaw values float pitch = 0; float roll = 0; float yaw = 0;

int button_pin=5; int button_state; void setup() { Serial.begin(115200);

// Initialize MPU605
while(mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G)) { Serial.println("Could not find a valid MPU6050 sensor, check wiring!"); delay(500); }

// Calibrate gyroscope. The calibration must be at rest. // If you don't want calibrate, comment this line. mpu.calibrateGyro();

// Set threshold sensivty. Default 3. // If you don't want use threshold, comment this line or set 0. mpu.setThreshold(3);

pinmode(button_pin,INPUT) }

void loop() {

int button_state=digitalRead(button_pin)

timer = millis();

// Read normalized values Vector norm = mpu.readNormalizeGyro();

// Calculate Pitch, Roll and Yaw pitch = pitch + norm.YAxis * timeStep; roll = roll + norm.XAxis * timeStep; yaw = yaw + norm.ZAxis * timeStep;

// Output raw Serial.print(" Pitch = "); Serial.print(pitch); Serial.print(" Roll = "); Serial.print(roll);
Serial.print(" Yaw = "); Serial.println(yaw);

// Wait to full timeStep period delay((timeStep*1000) - (millis() - timer)); }

   İf (pitch <=90 && pitch => 15 && button_state =(HIGH)){

}

#include <Wire.h>
#include <MPU6050.h>

MPU6050 mpu;

// Timers
unsigned long timer = 0;
float timeStep = 0.01;

// Pitch, Roll and Yaw values
float pitch = 0;
float roll = 0;
float yaw = 0;

int button_pin=5;
int button_state;
void setup() 
{
  Serial.begin(115200);

  // Initialize MPU605  
  while(mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G))
  {
    Serial.println("Could not find a valid MPU6050 sensor, check wiring!");
    delay(500);
  }
  
  // Calibrate gyroscope. The calibration must be at rest.
  // If you don't want calibrate, comment this line.
  mpu.calibrateGyro();

  // Set threshold sensivty. Default 3.
  // If you don't want use threshold, comment this line or set 0.
  mpu.setThreshold(3);

  pinmode(button_pin,INPUT)
}

void loop()
{

  int button_state=digitalRead(button_pin)

  timer = millis();

  // Read normalized values
  Vector norm = mpu.readNormalizeGyro();

  // Calculate Pitch, Roll and Yaw
  pitch = pitch + norm.YAxis * timeStep;
  roll = roll + norm.XAxis * timeStep;
  yaw = yaw + norm.ZAxis * timeStep;

  // Output raw
  Serial.print(" Pitch = ");
  Serial.print(pitch);
  Serial.print(" Roll = ");
  Serial.print(roll);  
  Serial.print(" Yaw = ");
  Serial.println(yaw);

  // Wait to full timeStep period
  delay((timeStep*1000) - (millis() - timer));
}

 
If (pitch <=90 && pitch => 15 && button_state =(HIGH))
{
}
deleted 39 characters in body
Source Link
arg3t
  • 31
  • 1
  • 4

I am having trouble with this code:

  `enter code here`  #include <Wire.h>

#include <Wire.h> #include <MPU6050.h>

MPU6050 mpu;

// Timers unsigned long timer = 0; float timeStep = 0.01;

// Pitch, Roll and Yaw values float pitch = 0; float roll = 0; float yaw = 0;

int button_pin=5; int button_state; void setup() { Serial.begin(115200);

// Initialize MPU6050MPU605
while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G)) { Serial.println("Could not find a valid MPU6050 sensor, check wiring!"); delay(500); }

// Calibrate gyroscope. The calibration must be at rest. // If you don't want calibrate, comment this line. mpu.calibrateGyro();

// Set threshold sensivty. Default 3. // If you don't want use threshold, comment this line or set 0. mpu.setThreshold(3);

pinmode(button_pin,INPUT) }

void loop() {

int button_state=digitalRead(button_pin)

timer = millis();

// Read normalized values Vector norm = mpu.readNormalizeGyro();

// Calculate Pitch, Roll and Yaw pitch = pitch + norm.YAxis * timeStep; roll = roll + norm.XAxis * timeStep; yaw = yaw + norm.ZAxis * timeStep;

// Output raw Serial.print(" Pitch = "); Serial.print(pitch); Serial.print(" Roll = "); Serial.print(roll);
Serial.print(" Yaw = "); Serial.println(yaw);

// Wait to full timeStep period delay((timeStep*1000) - (millis() - timer)); }

But when I add this code at the end I keep getting an error:

enter code here


But when I add this code at the end I keep getting an error:

İf (pitch <=90 && pitch => 15 && button_state =(HIGH)){

}

I know the issue is about the pitch part of the if. I just need to know how to fix it.

I am having trouble with this code:

  `enter code here`  #include <Wire.h>

#include <MPU6050.h>

MPU6050 mpu;

// Timers unsigned long timer = 0; float timeStep = 0.01;

// Pitch, Roll and Yaw values float pitch = 0; float roll = 0; float yaw = 0;

int button_pin=5; int button_state; void setup() { Serial.begin(115200);

// Initialize MPU6050 while(!mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G)) { Serial.println("Could not find a valid MPU6050 sensor, check wiring!"); delay(500); }

// Calibrate gyroscope. The calibration must be at rest. // If you don't want calibrate, comment this line. mpu.calibrateGyro();

// Set threshold sensivty. Default 3. // If you don't want use threshold, comment this line or set 0. mpu.setThreshold(3);

pinmode(button_pin,INPUT) }

void loop() {

int button_state=digitalRead(button_pin)

timer = millis();

// Read normalized values Vector norm = mpu.readNormalizeGyro();

// Calculate Pitch, Roll and Yaw pitch = pitch + norm.YAxis * timeStep; roll = roll + norm.XAxis * timeStep; yaw = yaw + norm.ZAxis * timeStep;

// Output raw Serial.print(" Pitch = "); Serial.print(pitch); Serial.print(" Roll = "); Serial.print(roll);
Serial.print(" Yaw = "); Serial.println(yaw);

// Wait to full timeStep period delay((timeStep*1000) - (millis() - timer)); }

enter code here


But when I add this code at the end I keep getting an error:

İf (pitch <=90 && pitch => 15 && button_state =(HIGH)){

}

I know the issue is about the pitch part of the if. I just need to know how to fix it.

I am having trouble with this code:

#include <Wire.h> #include <MPU6050.h>

MPU6050 mpu;

// Timers unsigned long timer = 0; float timeStep = 0.01;

// Pitch, Roll and Yaw values float pitch = 0; float roll = 0; float yaw = 0;

int button_pin=5; int button_state; void setup() { Serial.begin(115200);

// Initialize MPU605
while(mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G)) { Serial.println("Could not find a valid MPU6050 sensor, check wiring!"); delay(500); }

// Calibrate gyroscope. The calibration must be at rest. // If you don't want calibrate, comment this line. mpu.calibrateGyro();

// Set threshold sensivty. Default 3. // If you don't want use threshold, comment this line or set 0. mpu.setThreshold(3);

pinmode(button_pin,INPUT) }

void loop() {

int button_state=digitalRead(button_pin)

timer = millis();

// Read normalized values Vector norm = mpu.readNormalizeGyro();

// Calculate Pitch, Roll and Yaw pitch = pitch + norm.YAxis * timeStep; roll = roll + norm.XAxis * timeStep; yaw = yaw + norm.ZAxis * timeStep;

// Output raw Serial.print(" Pitch = "); Serial.print(pitch); Serial.print(" Roll = "); Serial.print(roll);
Serial.print(" Yaw = "); Serial.println(yaw);

// Wait to full timeStep period delay((timeStep*1000) - (millis() - timer)); }

But when I add this code at the end I keep getting an error:

   İf (pitch <=90 && pitch => 15 && button_state =(HIGH)){

}

I know the issue is about the pitch part of the if. I just need to know how to fix it.

Source Link
arg3t
  • 31
  • 1
  • 4
Loading