Zumo Control

i am using Zumo kit for my experiments, here i am trying to control my Zumo Robot with an accelerometer. i get input from accelerometer and check for the conditions. i used two “if” statements the problem is only one if statement (second if) is executing and other one is skipped by the machine. i inserted the code let me know the problem

#define LED_PIN 13
#include <ZumoMotors.h>
int turnright;
int x;
int turnleft;

ZumoMotors motors;
const int threshold1 = 280;
const int threshold2 = 300;


void setup() {
// initialize serial communication:
Serial.begin(9600);
pinMode(LED_PIN, OUTPUT);

}
 
void loop()
{
  x=analogRead(A0);
   
  turnright=map(x,310,370,0,50);
  turnright=constrain(turnright,0,50);
  turnleft=map(x,310,249,0,50);
  turnleft=constrain(turnleft,0,50);
 
 {if (x <= 280)
  {
      motors.setSpeeds(50,100);
 }
if (x >= 300)
{
motors.setSpeeds(100,50);
}
else {
   motors.setSpeeds(50, 50);
}

 }
Serial.print(x);
Serial.print('\t');
Serial.print(turnright);
Serial.print('\t');
Serial.print(turnleft);
Serial.print('\t');
Serial.println();

}
  x=analogRead(A0);

So. What value is stored in x? Why don't you know?

Why aren't you printing it HERE? Printing it later is useless.

Why are { there so { { {{ {{{ may useless } }} } } }} curly braces in } }{ your code?

X reads the analog vlaue from the sensor(accelerometer)

Printing is not actually my problem, the problem is system skips the first if statement and executes only second if statement and else statement.

the problem is system skips the first if statement and executes only second if statement and else statement.

It's probably having as much trouble with the useless curly braces and poor indenting as I am.

Get rid of the useless curly braces, and use Tools + Auto Format. Perhaps then it will be clear(er). If not, post your cleaned up code.