Battery sensing

I programed the brain If Battery capacity is less than 75 It will make two touchLED sensers red play a sound and print Low Battery CHANGE. When It was running the robot showed notting. Could anyone tell me how to fix this.

1 Like

put the if loop in a repeat forever? Im not really good at programming but it seems like it only checks for the battery level once then if it is not less than 75 it exits the if loop


That’s what I would think.

If you are using V5 there is a block that vibrates the controller. That’s what we use to indicate severe occurrences like battery percentage, if a motor is over worked etc… We also use it to indicate how much time is left in a game.


I am Iq also It did not work

In the example you just posted, it would just play the siren sound forever. You should only have the forever loop outside of the if statement, not inside it.

It did notting, It did not display text or made any touchled sensor red.

Did it make the siren sound?

I got it It was logic. As I put that part of the code last it was not working now when I keep it up front it works. Thanks for your help.

Nm I am comming with an error agein. When I lift the arm up the alarm goes off. I wonder there is a function.

Can you just post your entire code rather than sending that individual snippet?

1 Like

SecondareyTest (3).pdf (6.9 MB)

The voltage of NiMH batteries will probably drop when under load. You need to do some testing, start simple.
Have you tried just printing the capacity in % to screen when idle to see what it reads? Then set up a program to log what the lowest value is when driving/lifting etc. with a fully charged battery.
I am sure you will see a massive dip when driving/lifting.

1 Like

I saw it kept on changing 67 to 65.

For example:

A quick test. The program waits for a few seconds to let things settle after power on then takes the idle reading from the battery and stores it in a variable.
I can then power the motor using a button and put it under load. All the time, another variable is being updated with a the lowest reading achieved whilst the motor is running.

My battery is not fully charged, but saw similar to you (69 at idle) and dropped to minimum 46 under load.


Thanks it worked on my robot now when it hits 75% it alerts me with the red touchled sensor and the text input.