กลับไปหน้ารวมไฟล์
ky-016-straight-onto-uno-292139-en.md

This is a step in my bigger project about creating a spectacular light show with a bunch of bright RGB SMD LEDs. For that project I needed a software PWM library, because I need more PWM pins than there are hardware PWM pins on an Arduino UNO. In this project I test the SoftPWM library by Brett Hagman. Instead of using my bright RGB SMD LEDs, I just hooked the KY-016 into my UNO, because I noticed the pins of the KY-016 go directly as they are into three digital pins and one GND pin of the UNO.

KY-016

The KY-016 is an RGB LED on a small PCB including the required resistors for powering the LED with 5 V from the digital pins of the UNO. The KY-016 is included in the 37-in-1 sensor kit, which I believe is available from various manufacturers.

The pinout of the KY-016 is

  • R
  • G
  • B
  • GND or -

Pins I use on the UNO are

  • ~11
  • 12
  • 13
  • GND

The great thing is that these three pins are consecutive pins on the UNO. Just locate them! And stick your KY-016 into them!

~11 is a hardware PWM pin on the UNO (that's what the tilde (~) means), while pins 12 and 13 only perform digital out. So by writing analogWrite(11, 128); I could without further fuss get the led attached to pin 11 shine half dimmed. But pins 12 and 13 work properly only with digitalWrite(), either full bright or off.

Here's where the software PWM comes in handy. In short, it takes care of creating a PWM signal on any digital pin you want.

Create your own colour shows

My sample program "slides the R, G and B slides" through all combinations of full saturated colours in an RGB colour space. Create your own shows by altering the pattern of how the slides are moved. F.i. omit the blue colours, make the colours as warm as possible, restricting the colours to the spectral sector from red through yellow to green.

Figure out how to black out the two red LEDs on the UNO. In the following video you can see the bright red from the on board LEDs.

EXPANDED TECHNICAL DETAILS

RGB Multi-Color Interaction

The KY-016 is a basic but essential 3-color (RGB) LED module that serves as an introduction to color theory and PWM.

  • Common Cathode Architecture: Explains the direct wiring of the Red, Green, and Blue pins to the Arduino's PWM-enabled digital pins (e.g., 9, 10, 11).
  • Infinite Color Mixing: By varying the analogWrite() values (0-255) for the three channels, the Arduino can generate over 16 million potential colors, including soft pastels and vibrant primary tones.

Software Foundations

  • Hue-to-RGB algorithm: Includes a function that takes a single "Color Degree" (0-360) and automatically calculates the R, G, and B components for a smooth rainbow cycle.

ข้อมูล Frontmatter ดั้งเดิม

title: "KY-016 Straight Onto UNO"
description: "Got a KY-016? Stick it straight onto your UNO and start attracting unicorns! No soldering. No schematics. No freaking Fritzing."
author: "Johan_Ha"
category: "Lights & LEDs"
tags:
  - "softpwm"
  - "rgb led"
  - "pwm"
views: 8922
likes: 4
price: 99
difficulty: "Easy"
components:
  - "1x KY-016"
  - "1x Arduino UNO"
tools: []
apps:
  - "1x Arduino IDE"
downloadableFiles: []
documentationLinks: []
passwordHash: "f1f0eb00bfc638531d7e218570327e4c76118c1ea48210cb979c83afe8c97a3d"
encryptedPayload: "U2FsdGVkX1+CtASzMW7GI51pCUzszSFJE83aX77GherjmIfoeYv0vcqxUe/G+vvseqWFlBnkelMyxCwLXgi2nXIDfzFEQiVMdkiZu9IO90o="
seoDescription: "Plug the KY-016 directly into your UNO. No soldering, no schematics, and no Fritzing required for this quick Arduino setup."
videoLinks:
  - "https://www.youtube.com/embed/hpVUQLm4bOs"
  - "https://www.youtube.com/embed/t8OUS_Du4AE"
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/ky-016-straight-onto-uno-292139_cover.jpg"
lang: "en"