how to make an integer change based on battery percentage

:confused: basically i want
to do this but make a portable charger and have the screen and arrow represent battery percentage and have the arrow (servo) move left or right a certain amount depending on how much charge it has

do i make it read a serial analog value and then somehow convert it to power?

i took this code and added an integer with the value for the servo position

No problem. Use the IDE map function.

No problem. Use the IDE map function.

How’s that then?

You can only measure the charging voltage when you are charging and then you only measure the open terminal voltage of the thing you want to charge when you are Not charging.

What is the OP wanting to charge anyway?
Depending on the battery chemistry there can be little difference between a full battery and an almost exhausted one.

Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.... :slight_smile: