Arduino and Genuino 101 Development Workshop by Kurniawan Agus

Arduino and Genuino 101 Development Workshop by Kurniawan Agus

Author:Kurniawan, Agus
Language: eng
Format: epub, azw3, mobi
Publisher: PE Press
Published: 2016-02-28T16:00:00+00:00


In updateBatteryLevel() function, we read analog A0 and then update Battery level by calling setValue().

void updateBatteryLevel() { int battery = analogRead(A0); int batteryLevel = map(battery, 0, 1023, 0, 100); if (batteryLevel != oldBatteryLevel) { // if the battery level has changed Serial.print("Battery Level % is now: "); // print it Serial.println(batteryLevel); batteryLevelChar.setValue(batteryLevel); // and update the battery level characteristic oldBatteryLevel = batteryLevel; // save the level for next comparison } }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.