Get Main Battery LED's

I would like to know if there is a way to tell how much battery is left without going to the tools on easyC (yes I use easyC). I found a get battery function but I don’t know how to take that amount and use it to turn a red LED on if it’s running low. Some help would be very much appreciated. Thanks (in advance)

If you want to know when the battery is not on the robot, you can use a standard voltmeter. You could check the voltage before the match and then know that you are either good or need a different.

Have you heard of an LCD Display? Using it, you can show the battery voltages during a match or just whenever. I don’t know if it can work on easyc because I have never used it, but on robotc there is a sample program that is very simple. Works great.

http://www.vexrobotics.com/276-2273.html

The cortex already indicates if the voltage of the battery drops below 6.5V (yellow robot led) or 5.5V (red robot led). However, if you want to do that yourself, or use different values, then you can use the GetMainBattery function.

Here is a user function that displays the battery voltage on the LCD and then sets a LED in digital output 12 if it is below 7 volts. This will not latch the led on, you would need some more simple logic if you wanted to do that.

[ATTACH]9117[/ATTACH]

Call from operator control as follows.

[ATTACH]9118[/ATTACH]

Battery voltage does not tell the whole story about how much energy a battery has left, it will change as you start and stop your motors.
easyc_battery_2.jpg
easyc_battery_1.jpg

My team uses our LCD to display our battery voltage for both the cortex and the Power Expander. We programmed it with easyC. What we did was:

In the initialize function: start the LCD and turn on the backlight

In the driver control function: Inside of the while loop, get the battery life (returns a float) but since the print to LCD can only print an int because of the %d directive, we multiply by 100 and change to an int, then print that. For the power expander battery, we plugged a 3-wire cord from the status port into an analog input, got that integer, divided it by a number which can
be found on the VEX wiki page for the power expander (based on which model of the power expander we had and returned that to a float. We then multiplied that float by 100 and changed it to an int which we printed

Hope this helps!

Select %f from the dropdown menu and that will allow displaying a float. Type in the box (where the %d or %f is displayed) and you can change the format in any way you like. See my post below for an example.

Thanks Guys. I Liked Jpearmans Idea seeing as how the “y” team at my school is using the only lcd display. I will certainly do that.

Can someone show me a screen shot of their code with the lcd obtaining the battery voltage from the power expander. I cant get it correct and need some help