插上鋰電池,把圖中的指撥開關切到「BAT」,代表從電池汲取電力。LinkIt ONE板子上有三個指撥開關,非常重要,詳細意義請看這篇。
#include <LBattery.h>
#define BAUDRATE 19200
void setup(){
Serial.begin(BAUDRATE);
}
void loop(){
Serial.print("Battery level is ");
Serial.println(LBattery.level());
Serial.print("Charging: ");
Serial.println(LBattery.isCharging() ? "yes" : "no");
delay(5000);
}
開啟序列埠監控視窗,輸出訊息大概如下:
No comments:
Post a Comment