"""#---------------------------------------------------------
A little program to demostrate to my nephew that there are
three primary colours that when mixed in various quatities
produces millions of secondary colours.
=========================
In this program an RGB LED is connected to Pico.The three
colours of the LED are flashed randomly every 500ms
Author: Henderson Hood
File : RGB.py
Date : July, 2023
----------------------------------------------------------
"""
from machine import Pin
import utime
import random
# GPIO pins used by the RGB LED
Red = Pin(3, machine.Pin.OUT)
Green = Pin(4, Pin.OUT)
Blue = Pin(5, Pin.OUT)
while True:
"""
Here we mix varying quatities of the 3 primary colours to
produce numerous colours. Each mixture produces a different colour.
0 means zero add, 1 means max added.
"""
r = random.randint(0, 1) #amount of Red to add
g = random.randint(0, 1) #amount of Green to add
b = random.randint(0, 1) #amount of Blue to add
#we store various degress of the primary color in LED; this happens
#so fast that our eyes interpret the mixtures as different colours.
Red.value(r)
utime.sleep(0.2)
Green.value(g)
utime.sleep(0.2)
Blue.value(b)
utime.sleep(0.2)