Battery operated flashlight whose intensity decreases with time

Hey people. I’m new to programming and I wanted to ask you guys that how can I make a battery operated flashlight whose intensity decreases with the decrease of battery life? If someone can just give a C++ code for that, that would be great.

Does this help for a start? <3

Flashlight in C++

Hey, could you make something work with the tutorial I’ve send? Would be great to hear back and if there is no more questions, please make sure to checkout your question! <3