> For the complete documentation index, see [llms.txt](https://ubtechedu.gitbook.io/chinese/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ubtechedu.gitbook.io/chinese/standard/onborad/readbatteryvoltage.md).

# readBatteryVoltage()

获取电池电压

### 返回

| 参数名    | 类型    | 描述            |
| ------ | ----- | ------------- |
| number | float | 电压值，范围0\~8.4V |

### 例子

用uKitExplore v2板子,接入电池和1号舵机，然后打开开关。设置当电池电压小于7.2V时蜂鸣器报警红灯亮并停止舵机工作,程序不再运行。若大于则舵机转动

```c
#include "uKitExplore2.h"
void setup() {    
    Initialization();
}

void loop() {    
    if(readBatteryVoltage()<=7.2){	
        setServoStop(1);	
        tone(131,400);	
        setRgbledColor(255,0,0);	
        while(1);    
    }    
    else{	
        setServoTurn(1,0,80);
    }
}
```
