Answers.Body: <p>Short answer: You can't.</p>
  <p>Longer answer: It should be possible to do with custom firmware, but it's (a) not worth it, (b) difficult from a technical standpoint, and (c) a bad idea.</p>
  <p>Disclaimer: besides being an AFOL, I have some experience in the microelectronics industry.</p>
  <h4>What's this &quot;firmware&quot; thing, anyway?</h4>
  <p>When you load a program into a spike/mindstorms/ev3/etc hub, the hub is not running <em>just</em> your program. It's running a lot of stuff under the hood.</p>
  <p>In fact, your program (i.e. &quot;the user program&quot;) does not communicate with the hardware (motors/sensors) directly. It communicates to the <em>operating system</em> of the hub. That's commonly called &quot;<a href="https://en.wikipedia.org/wiki/Firmware" rel="nofollow noreferrer">firmware</a>&quot; since it lays somewhere in between &quot;hardware&quot; and &quot;software&quot;. It's assumed to be immutable and reliable as hardware, but with some effort can be changed/updated as software.</p>
  <p>The firmware handles the tricky bits of computing that you don't want to care about - such as the <a href="https://en.wikipedia.org/wiki/Pulse-width_modulation" rel="nofollow noreferrer">Pulse-Width Modulation</a> for the LED colours, the <a href="https://en.wikipedia.org/wiki/Real-time_clock" rel="nofollow noreferrer">Real-Time Clock</a> to run commands for specific amounts of time, or the USB and <a href="https://en.wikipedia.org/wiki/Bluetooth_Low_Energy" rel="nofollow noreferrer">BLE</a> network stacks to communicate with desktop/laptop computers.</p>
  <p>Note that your user programs do <strong>not</strong> have full control over the hardware, or over all the features of the OS. For example: any device with a USB stack and a button can be (in theory) converted into a USB mouse (technically a &quot;<a href="https://en.wikipedia.org/wiki/USB_human_interface_device_class" rel="nofollow noreferrer">USB HID</a>&quot;)</p>
  <h4>Why is it not worth it?</h4>
  <p>Because it takes a lot of time; and given the amount of person-hours that it would take to develop custom firmware (such a <a href="https://github.com/pybricks" rel="nofollow noreferrer"><code>pybricks</code></a>, the only non-lego™ firmware I'm aware of), you'd be way better off getting an <a href="https://www.arduino.cc" rel="nofollow noreferrer">Arduino</a> and/or a <a href="https://www.raspberrypi.com/news/raspberry-pi-build-hat-lego-education/" rel="nofollow noreferrer">Raspberry Pi</a>. That way you can learn to take full(er) control of your hardware.</p>
  <p>Or, if you just need extra lights, get set <a href="https://www.bricklink.com/v2/catalog/catalogitem.page?S=88005-1" rel="nofollow noreferrer">88005-1</a>.</p>
  <p>I'm assuming you are reading this from the point of view of a person just learning computing/robotics. If you already have experience in computing, tweaking <code>pybricks</code> or even <a href="https://www.zephyrproject.org/" rel="nofollow noreferrer">Zephyr</a> wouldn't be out of the question.</p>
  <h4>Why is it so difficult?</h4>
  <p>I've skimmed the source code for the <code>pybricks</code> firmware. As far as I can see, the code paths for the user-programmable RGB LED and the battery LED are completely different. The former is treated as a peripheral, but the later is treated as <em>process events passed to the underlying <a href="https://github.com/contiki-os/contiki" rel="nofollow noreferrer">kontiki</a> OS</em>.</p>
  <p>So in order to make the battery LED user-programmable, first you would need to disable it at a lower level. Which means losing the default behaviour for that LED.</p>
  <h4>Why is this a bad idea?</h4>
  <p>When developing low-level firmware, the ways that the computer (the hub) can display information are <strong>very</strong> limited. I'm talking no bluetooth, no USB, no UART: a status LED is in most cases the only tool available. Losing that tool  is plain dangerous.</p>
  <p>From a support point of view, <em>letting a user fake the behaviour of that tool</em> means that you couldn't trust problem reports. If a LED is stuck on a colour, how can you be sure that it's a problem with the OS, or maybe is it a problem with the user's program?</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-15T15:12:02.593Z
Answers.LastActivityDate: 2022-08-15T15:12:02.593Z
Answers.UserDisplayName: IvanSanchez
Answers.Body: <p>As far as I know, this is not possible with the default firmware and APIs currently. The primary hub LED is exposed as <a href="https://lego.github.io/MINDSTORMS-Robot-Inventor-hub-API/pkg_hub.html#hub.led" rel="nofollow noreferrer"><code>hub.led</code></a>, but I don't believe that the other LED is accessible from user code.</p>
  <p>It may be possible to access it in some undocumented way or via custom firmware, but I'm not familiar with any way to do this.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-08-15T13:29:59.593Z
Answers.LastActivityDate: 2022-08-15T13:29:59.593Z
Answers.UserDisplayName: jncraton
Body: <p>I have the <a href="https://brickset.com/sets/51515-1/Robot-Inventor" rel="nofollow noreferrer">Mindstorms set 51515 - Robot Inventor</a>. I want to display the progress of a robot's work using the LEDs.</p>
  <p>How can I change the colour of the RGB LED that the hub uses to indicate the Bluetooth/charging status?</p>
  
Tags: <mindstorms><programming><python><robot-inventor><micropython>
Title: How to change colour of the bluetooth/charging RGB LED in the hub?
UserDisplayName: Wolfi_HD1
ThreadText: # How to change colour of the bluetooth/charging RGB LED in the hub?
  
  (Asked by: username_0 on 2022-08-13)
  
  I have the [Mindstorms set 51515 - Robot Inventor](https://brickset.com/sets/51515-1/Robot-Inventor). I want to display the progress of a robot's work using the LEDs.
  
  How can I change the colour of the RGB LED that the hub uses to indicate the Bluetooth/charging status?
  
  **Tags:** mindstorms, programming, python, robot-inventor, micropython
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2022-08-15. Score: 4
  
  Short answer: You can't.
  
  Longer answer: It should be possible to do with custom firmware, but it's (a) not worth it, (b) difficult from a technical standpoint, and (c) a bad idea.
  
  Disclaimer: besides being an AFOL, I have some experience in the microelectronics industry.
  
  #### What's this "firmware" thing, anyway?
  
  When you load a program into a spike/mindstorms/ev3/etc hub, the hub is not running *just* your program. It's running a lot of stuff under the hood.
  
  In fact, your program (i.e. "the user program") does not communicate with the hardware (motors/sensors) directly. It communicates to the *operating system* of the hub. That's commonly called "[firmware](https://en.wikipedia.org/wiki/Firmware)" since it lays somewhere in between "hardware" and "software". It's assumed to be immutable and reliable as hardware, but with some effort can be changed/updated as software.
  
  The firmware handles the tricky bits of computing that you don't want to care about - such as the [Pulse-Width Modulation](https://en.wikipedia.org/wiki/Pulse-width_modulation) for the LED colours, the [Real-Time Clock](https://en.wikipedia.org/wiki/Real-time_clock) to run commands for specific amounts of time, or the USB and [BLE](https://en.wikipedia.org/wiki/Bluetooth_Low_Energy) network stacks to communicate with desktop/laptop computers.
  
  Note that your user programs do **not** have full control over the hardware, or over all the features of the OS. For example: any device with a USB stack and a button can be (in theory) converted into a USB mouse (technically a "[USB HID](https://en.wikipedia.org/wiki/USB_human_interface_device_class)")
  
  #### Why is it not worth it?
  
  Because it takes a lot of time; and given the amount of person-hours that it would take to develop custom firmware (such a [`pybricks`](https://github.com/pybricks), the only non-lego™ firmware I'm aware of), you'd be way better off getting an [Arduino](https://www.arduino.cc) and/or a [Raspberry Pi](https://www.raspberrypi.com/news/raspberry-pi-build-hat-lego-education/). That way you can learn to take full(er) control of your hardware.
  
  Or, if you just need extra lights, get set [88005-1](https://www.bricklink.com/v2/catalog/catalogitem.page?S=88005-1).
  
  I'm assuming you are reading this from the point of view of a person just learning computing/robotics. If you already have experience in computing, tweaking `pybricks` or even [Zephyr](https://www.zephyrproject.org/) wouldn't be out of the question.
  
  #### Why is it so difficult?
  
  I've skimmed the source code for the `pybricks` firmware. As far as I can see, the code paths for the user-programmable RGB LED and the battery LED are completely different. The former is treated as a peripheral, but the later is treated as *process events passed to the underlying [kontiki](https://github.com/contiki-os/contiki) OS*.
  
  So in order to make the battery LED user-programmable, first you would need to disable it at a lower level. Which means losing the default behaviour for that LED.
  
  #### Why is this a bad idea?
  
  When developing low-level firmware, the ways that the computer (the hub) can display information are **very** limited. I'm talking no bluetooth, no USB, no UART: a status LED is in most cases the only tool available. Losing that tool is plain dangerous.
  
  From a support point of view, *letting a user fake the behaviour of that tool* means that you couldn't trust problem reports. If a LED is stuck on a colour, how can you be sure that it's a problem with the OS, or maybe is it a problem with the user's program?
  
  
  ---
  
  ### Answer by username_2 on 2022-08-15. Score: 3
  
  As far as I know, this is not possible with the default firmware and APIs currently. The primary hub LED is exposed as [`hub.led`](https://lego.github.io/MINDSTORMS-Robot-Inventor-hub-API/pkg_hub.html#hub.led), but I don't believe that the other LED is accessible from user code.
  
  It may be possible to access it in some undocumented way or via custom firmware, but I'm not familiar with any way to do this.
  
  
  ---
  
  