SubName: Show your battery level on a purpose made mini battery display.
Description: Here is a quick example of inline C being used to power a mini battery display. As there's no library for this display on the forum, I used inline C with the original Arduino IDE source code.
I've slimmed down the inline C code to make it easier to read. You can find the original library on Github, just copy the library files into your Arduino IDE library folder and use the code below.
Tags: Mini, Battery, Module, Arduino, Inline, C, C++
An UNO board running a mini battery display.
Enjoy...
Description: Here is a quick example of inline C being used to power a mini battery display. As there's no library for this display on the forum, I used inline C with the original Arduino IDE source code.
I've slimmed down the inline C code to make it easier to read. You can find the original library on Github, just copy the library files into your Arduino IDE library folder and use the code below.
B4X:
'WIRE LEGEND for TM1651 battery display
'VCC = 3.3V to 5V
'GND = GND
'CLK = D4
'DIO = D2
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
RunNative("setup", Null)
AddLooper("Loopey")
End Sub
Sub Loopey
RunNative("loop", Null)
End Sub
#if C
#include "TM1651.h"
#define CLK 4
#define DIO 2
TM1651 batteryDisplay(CLK, DIO);
void charging()
{
for(uint8_t level = 0; level < 8; level ++)
{
batteryDisplay.displayLevel(level);
delay(500);
}
}
void setup(B4R::Object* unused)
{
batteryDisplay.init();
batteryDisplay.set(2); //Set brightness from 0 to 7
}
void loop(B4R::Object* unused)
{
charging();
}
#End if
Tags: Mini, Battery, Module, Arduino, Inline, C, C++
An UNO board running a mini battery display.
Enjoy...
Last edited: