===== Color chooser ===== This example shows how two potentiometers can be used to choose an RGB led. ==== Requirements: ==== * Uper1 board * Two potentiometers * Breadboard * Connection wires ==== Schematic: ==== {{ :examples:uper:1:07_adc.png?direct&480 |}} ==== Code: ==== from colorsys import hls_to_rgb from IoTPy.pyuper.uper import UPER1 with UPER1() as board, \ board.ADC("ADC0") as adcPin1, board.ADC("ADC1") as adcPin2, \ board.PWM("PWM0_0", polarity=0) as redPin,\ board.PWM("PWM0_1", polarity=0) as greenPin,\ board.PWM("PWM0_2", polarity=0) as bluePin: while True: hue = adcPin1.read() lightness = adcPin2.read() rgb = hls_to_rgb(hue, lightness, 1) redPin.set_duty_cycle(rgb[0]*100) greenPin.set_duty_cycle(rgb[1]*100) bluePin.set_duty_cycle(rgb[2]*100)