Would It be posible for a gyro to detect if you were on the left or right side of the areena and start code automaticaly bassed on what side the robot is on?
It depends your definition. Technically, you could combine code and have a gyro to detect how you place it or something. Or you could use other sensors, such as if a button is pressed it will do the other program. Or a distance sensor detecting the distance to the wall.
You could use a gyro sensor, but I think it would be as useful as any other sensor.
For a project we had to program a robot to move around inner perimeter of the VRC field. Part of the criteria for the task was that it could go both clock-wise and anti-clockwise around the field. To do this automatically we used a distance sensor which would detect the direction the robot is facing (i.e., is there a wall on the left, therefore clockwise, or no wall, therefore anti-clockwise).
As the autonomous period at the start of the match is often about speed of the robot, it would be wiser to save time during the match by having two separate programs or one which you can switch between using like a touch sensor as a button. It’s also less likely to go wrong - because autonomous programs are known to go wrong.
Tracking your robot’s pose (position and heading) would allow you to do this.
Unfortunately, using only a gyroscope would not work well. Gyro’s are only really accurate in the short term, and while you can integrate the angular velocity vectors to get your pitch, yaw, and roll, they have a good deal of bias and drift. But, even if they had no bias or drift, you still wouldn’t be able to determine your position with the gyro alone since the system is discretized.
The simple solution is to use your wheel encoders and work out the forward kinematics (lots of resources available on this, you can use the instantaneous center technique or some sort of derivative approximation like a taylor series or a Padé approximant) to find your position and heading from a given left and right wheel speed.
If you want to get a little fancy, you can combine wheel encoder readings with a gyro and an accelerometer (this helps keep track of your heading over longer periods of time), and a complementary filter (a basic Kalman filter with like k = 0.95 would suffice; this would weight the gyro readings more than the accelerometer readings, but still allow for the accelerometer to correct your heading over time).
position tracking is a pretty broad topic but hopefully this at least gets you started
ok so after rereading your post I realize that you asked a slightly different question than what I answered lol but what I said still applies to some degree
I just used a potentiometer that if it is starting on one side I turn the potentiometer to that side, and i have the code run a different program using if statements