Charger Design Specifications
#define) to match your PCB routing.Cpp
/* * Wireless-controller charging LED * Works with MCP73831 STAT pin (active-LOW while charging) * Target MCU: nRF52840, Arduino-core */ #include <Arduino.h> /* ---------- Pin definitions (edit to match your board) ---------- */ #define PIN_STAT 11 // nRF52840 P0.11 <-- MCP73831 STAT #define PIN_LED 13 // nRF52840 P0.13 <-- Green LED anode (active-HIGH) /* ---------------------------------------------------------------- */ void setup() { // STAT input: pull-up because MCP73831 is open-drain pinMode(PIN_STAT, INPUT_PULLUP); // LED output (start OFF) pinMode(PIN_LED, OUTPUT); digitalWrite(PIN_LED, LOW); // Optional: lower CPU speed for power-save if BLE not used // NRF_CLOCK->TASKS_HFCLKSTOP = 1; // stop external 64 MHz crystal } void loop() { bool charging = (digitalRead(PIN_STAT) == LOW); // LOW = charging digitalWrite(PIN_LED, charging ? HIGH : LOW); // Sleep 250 ms; Arduino-nRF52 core will enter low-power idle delay(250); }
Bash
arduino-cli board attach arduino:mbed_nano:nano33ble arduino-cli compile --fqbn arduino:mbed_nano:nano33ble arduino-cli upload -p /dev/ttyACM0 --fqbn arduino:mbed_nano:nano33ble