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

This circuit 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 circuit includes several resistors to limit current and an electrolytic capacitor for debouncing the joystick button. The Raspberry Pi Pico W is programmed to read the joystick's position and to control the brightness and color of the LED based on the joystick's input.

Component List

LED: Four Pin

Resistor (330 Ohms)

Resistor (10 kOhms)

Resistor (100 kOhms)

Electrolytic Capacitor (0.00022 Farads)

Raspberry Pi Pico W

KY-023 Dual Axis Joystick Module

Wiring Details

LED: Four Pin

Resistor (330 Ohms)

Resistor (10 kOhms)

Resistor (100 kOhms)

Electrolytic Capacitor (0.00022 Farads)

Raspberry Pi Pico W

KY-023 Dual Axis Joystick Module

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 definitions for the RGB function and the forward and backward sequences.
# The code for rainbow.py is not provided here but should be saved with a .py extension.

documentation.txt

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 the logic for the color transitions and the joystick interaction.
# The code for sketch.ino is not provided here but should be saved with a .py extension.

Note: The provided code snippets are written in Python and are intended to be used with the Raspberry Pi Pico W's MicroPython environment. The file extensions mentioned in the documentation (.ino) are typically associated with Arduino sketches, which may be a mistake in the documentation. The correct file extension for MicroPython scripts is .py.