user36785: The closest thing I can find is if(Serial) but that only returns true if there's a serial port open.
The function I want, ideally, should:
Return true if plugged into a computer
Return false if plugged into a USB power bank
Return false if not plugged in at all(Running off of its own lithium cell)

user368: ADDEN of UDADDR is set if the '32U4 has been assigned a USB address by the host and the firmware wants to enable USB connectivity.
UDADDR & _BV(ADDEN)


36785: <p>The closest thing I can find is if(Serial) but that only returns true if there's a serial port open.</p>

<p>The function I want, ideally, should:</p>

<p>Return true if plugged into a computer</p>

<p>Return false if plugged into a USB power bank</p>

<p>Return false if not plugged in at all(Running off of its own lithium cell)</p>
 368: <p><code>ADDEN</code> of <code>UDADDR</code> is set if the '32U4 has been assigned a USB address by the host and the firmware wants to enable USB connectivity.</p>

<pre><code>UDADDR &amp; _BV(ADDEN)
</code></pre>
