How to define global variable

Hello , im new here. and me english is wrong.

I need declare variable “batery” , but it must be global because i have the next error
image

in this function i use that variable

thanks guys!