Searching for info regarding the PS2X Library

It works!

This could also be done if the controller suddenly cuts off so maybe your adapter is not getting enough current or a stable 3.3 voltage. If you want, you can debug and use some serial prints to see what values are being sent to the robot.

Plugged a 9V into the Arduino and it works fine! I presume when the motors pulling alot of current it was causing voltage fluctuations. The receiver was just cutting out and reading the analog value as zero like you said.

I was hoping to create a fail safe in case the controller disconnects for some other foreseen reason. Ive been testing it by recreating the issue I just resolved.

I tried using the

if(error==1)
{
return;
}

like in your code but it didn't fix the issue.