Arduino RGB LED 透明

发布于 2024-12-19 09:47:23 字数 519 浏览 2 评论 0原文

我有一个 RGB LED,有 9、10、11 引脚和接地引脚。 已为 R、G 和 B 提供了电阻器。

当我这样做时:

  analogWrite(r, 255); // I see a red color
  analogWrite(g, 0);
  analogWrite(b, 0);

  analogWrite(r, 0);
  analogWrite(g, 255); // I see a green color
  analogWrite(b, 0);

  analogWrite(r, 0);
  analogWrite(g, 0); // I see a blue color
  analogWrite(b, 255);

当我这样做时:

  analogWrite(r, 153);
  analogWrite(g, 102);
  analogWrite(b, 51);

在我看来,它看起来不是棕色的,更像是蓝色。 我是否错过了一些我需要做的事情?

I have an RGB LED and have pins to 9, 10, 11 and a pin to ground.
Resistors have been provided for R, G, and B.

When I do:

  analogWrite(r, 255); // I see a red color
  analogWrite(g, 0);
  analogWrite(b, 0);

  analogWrite(r, 0);
  analogWrite(g, 255); // I see a green color
  analogWrite(b, 0);

  analogWrite(r, 0);
  analogWrite(g, 0); // I see a blue color
  analogWrite(b, 255);

When I do:

  analogWrite(r, 153);
  analogWrite(g, 102);
  analogWrite(b, 51);

it does not look brown to me, more like a blue color.
Am I missing something I need to do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

请止步禁区 2024-12-26 09:47:23

棕色是一种很难实现的颜色。 (它实际上是深红色。棕色不在彩虹中。)

确保您的颜色平衡:写下暗白色/灰色、128、128、128,并确保它看起来是白色的。然后写下 255, 255,255 并确保它看起来是白色的。如果这些看起来不是白色,请调整电阻器以减少流过太亮组件的电流(注意不要允许太大的电流并烧坏 LED。

Brown is a very difficult color to achieve. (It's actually dark red. Brown isn't in the rainbow.)

Make sure that your colors are balanced: write a dim white / gray, 128, 128, 128 and make sure this looks white. Then write a 255, 255,255 and make sure this looks white. If these don't look white, adjust your resistors to reduce current through the component that is too bright (be careful not to allow too much current and burn out the LED.

梦途 2024-12-26 09:47:23

Brown color example

它很奇怪,但蓝色似乎与您想要实现的棕色完全相反。此外,当我尝试反转颜色(255 - x)时,我得到了蓝色。也许 PWM 配置有问题?

Brown color example

Its weird, but blue color seems exactly opposite to brown color, that you are trying to achieve. Moreover, when I've tried to invert the color (255 - x), I've got blue colors. Maybe something is wrong with PWM configuration?

耳钉梦 2024-12-26 09:47:23

RGB LED是共阳极还是共阴极,

通常RGB LED是共阳极的。
这意味着:降低analogWrite值,提高亮度(发出更多光)

http://www.hertaville.com/wp-content/ uploads/2011/07/rgb.jpg

你还需要电阻,注意在电阻相同的情况下,蓝色比绿色或红色发出更多的光,所以你需要设置更高的值电阻值。

is the RGB LED common anode or common cathode,

usually RGB LEDs are common anode.
this means: lowwer the analogWrite value, higher brightness (more emitted light)

http://www.hertaville.com/wp-content/uploads/2011/07/rgb.jpg

you also need resistors, notice that blue emits more light with the same value of resistans, than green or red, so you need to set a higher resistor value.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文