It appears you are using an inappropriate battery, 9V smoke alarm batteries do not have enough power to support your project. I expect your code will run OK when connected to the computer but not so when not connected.
so what branded typed batteries are the best
Sorry I cannot answer that, I am not that familiar with them but by there rating they will not last long at best. Get either a power supply or a battery holder that has 6 AA batteries or larger 1.5V in series. There are other types and rechargeable. You want at least 7.5V for the connector to power the Arduino.
thank you!
A discharged battery might be the problem. You can use the USB port to power the Arduino.
