Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Raspberry Pi Pico W Controlled RGB LED with Joystick Interaction

View and Edit Project In Cirkit DesignerImage of Raspberry Pi Pico W Controlled RGB LED with Joystick Interaction

Circuit Documentation

Summary

The circuit in question is designed to interface a Raspberry Pi Pico W with a KY-023 Dual Axis Joystick Module and a multi-color LED with four pins (common anode configuration). The Raspberry Pi Pico W reads the joystick position and controls the color of the LED based on the joystick's position. The LED's individual color channels (red, green, and blue) are connected through resistors to the Raspberry Pi Pico W's PWM-capable pins, allowing for color mixing and brightness control.

Component List

Raspberry Pi Pico W

KY-023 Dual Axis Joystick Module

LED: Four Pin

Resistor (3x)

Wiring Details

Raspberry Pi Pico W

KY-023 Dual Axis Joystick Module

LED: Four Pin

Resistor (3x)

Documented Code

main.py

## main.py

#include modules
from machine import Timer, ADC, PWM
from utime import sleep
import rainbow

# declaring objects from PWM and ADC classes
joystickY = ADC(26)
redLED = PWM(18, freq = 100, duty_u16 = 0, invert = 1)
greenLED = PWM(17, freq = 100, duty_u16 = 0, invert = 1)
blueLED = PWM(16, freq = 100, duty_u16 = 0, invert = 1)

while True:
    valueY = joystickY.read_u16()
    rainbow.RGB(valueY, redLED, greenLED, blueLED, joystickY)
    sleep(.01)  # in seconds

rainbow.py

# rainbow.py contains the RGB function used to control the LED color based on the joystick position.
# The actual content of rainbow.py is not provided here, but it should be saved with a .py extension.

Documentation Note

main.ino is the main.py program
rainbow.py.txt is the rainbow.py program

save these as .py extensions only

sketch.ino

// sketch.ino contains helper functions for the main.py program.
// It defines the forward_sequence, backward_sequence, and RGB functions.
// These functions are used to create a rainbow effect on the LED based on the joystick's Y-axis position.
// The actual content of sketch.ino is not provided here, but it should be saved with a .py extension.

Note: The code provided is in Python, and the file extensions mentioned as .ino are typically associated with Arduino sketches. The documentation note suggests saving the files with .py extensions, which is consistent with Python code for the Raspberry Pi Pico W.