> For the complete documentation index, see [llms.txt](https://monasheng.gitbook.io/zerotohero/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://monasheng.gitbook.io/zerotohero/arduino-zero-to-hero/module-capstone-project/colour-mixing-tasks.md).

# Colour Mixing Tasks

Using a PWM signal rather than a fixed digital one, you can build up mixed colours by varying the effective input voltage to each individual diode within the external LED.&#x20;

The PWM duty cycle `[0-255]` dictates the brightness of each individual diode, and thus the colour mix.

For instance, the following colours can be easily made:

| Output Colour | Red \[PWM Amount] | Green \[PWM Amount] | Blue \[PWM Amount] |
| ------------- | ----------------- | ------------------- | ------------------ |
| Red           | 255               | 0                   | 0                  |
| Orange        | 230               | 126                 | 34                 |
| Yellow        | 241               | 196                 | 15                 |
| Green         | 0                 | 255                 | 0                  |
| Blue          | 0                 | 0                   | 255                |
| Indigo        | 155               | 89                  | 182                |
| Violet        | 142               | 68                  | 173                |

## Task 14 - Make a custom colour

* [x] Re-wire each of the external LEDS to use *analog output/PWM* compatible pins.
* [x] Open a new Arduino Sketch.
* [x] Pick your favourite colour from the table above, but do not choose red, green, or blue (these are trivial!).
* [x] Write a simple program to:
  * [x] Show your favourite colour on the LED, by illuminating the `RED`, `GREEN`, and `BLUE` LEDs with PWM waveforms of appropriate duty cycle.
* [x] Verify and Flash this code using the IDE.
* [x] `File -> Save As...` your sketch for later use.

## Task 15 - Adjust the brightness of your  custom colour

* [x] Write a simple program to:
  * [x] Display your custom colour, gradually increasing the brightness from off to on.
    * [x] Once fully-on, return to off and start over.
    * [x] You can use a loop and/or the `delay()` function as needed to demonstrate this.

{% hint style="info" %}
:man\_mage: **Hint:** Think about what it means to increase/decrease the brightness of the LED as a whole while maintaining your custom colour. What needs to change?
{% endhint %}

* [x] Verify and Flash this code using the IDE.
* [x] `File -> Save As...` your sketch for later use.
