Issue with primary expression before “<" token

I'm just trying to turn the built-in LED on Arduino Uno to high when a negative acceleration is reached in the Z axis. When I compile the code it gives the error listed in the title of primary expression before token. The second if statement is where I'm getting the error occurring. Any idea on how to fix this?

#include <MPU6050_tockn.h> #include <Wire.h> MPU6050 mpu6050(Wire); long timer = 0; void setup() { Serial.begin(9600); Wire.begin(); mpu6050.begin(); mpu6050.calcGyroOffsets(true); } void loop() { mpu6050.update(); if(millis() - timer > 1000){ float accelZ = (mpu6050.getAccZ()); Serial.print("Still active"); Serial.println("======================================================="); Serial.print("temp : ");Serial.println(mpu6050.getTemp()); Serial.print("accX : ");Serial.print(mpu6050.getAccX()); Serial.print("\taccY : ");Serial.print(mpu6050.getAccY()); Serial.print("\taccZ : ");Serial.println(mpu6050.getAccZ()); if (accelZ) < 0.0 { digitalWrite(LED_BUILTIN, HIGH); } else { digitalWrite(LED_BUILTIN, HIGH); } Serial.print("gyroX : ");Serial.print(mpu6050.getGyroX()); Serial.print("\tgyroY : ");Serial.print(mpu6050.getGyroY()); Serial.print("\tgyroZ : ");Serial.println(mpu6050.getGyroZ()); Serial.print("accAngleX : ");Serial.print(mpu6050.getAccAngleX()); Serial.print("\taccAngleY : ");Serial.println(mpu6050.getAccAngleY()); Serial.print("gyroAngleX : ");Serial.print(mpu6050.getGyroAngleX()); Serial.print("\tgyroAngleY : ");Serial.print(mpu6050.getGyroAngleY()); Serial.print("\tgyroAngleZ : ");Serial.println(mpu6050.getGyroAngleZ()); Serial.print("angleX : ");Serial.print(mpu6050.getAngleX()); Serial.print("\tangleY : ");Serial.print(mpu6050.getAngleY()); Serial.print("\tangleZ : ");Serial.println(mpu6050.getAngleZ()); Serial.println("=======================================================\n"); timer = millis(); } } 

Touch here for the full post on the Arduino Apprentices tumblr

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s