Introduction
Every Brick has a way to detect the voltage of the Battery.
1. How to use the sensor
1.1. Read the voltage
package ev3dev.sensors;
import lejos.utility.Delay;
public class BatteryDemo {
public static void main(String[] args) {
final Battery battery = Battery.getInstance();
for(int x = 0; x < 20; x++){
System.out.println("Battery Voltage: " + battery.getVoltage());
Delay.msDelay(1000);
}
}
}