这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » DIY与开源设计 » 电子DIY » Let'sdo2025年第3期——拾音器-板载RGB显示当前颜色

共1条 1/1 1 跳转至

Let'sdo2025年第3期——拾音器-板载RGB显示当前颜色

菜鸟
2025-12-02 21:18:01     打赏

要实现板载RGB控制所以我们需要找到对应的引脚,我们根据原理图可以查看到其中的引脚在33引脚上。

image-20251025205000740

image-20251025205035164

我们在arduino找到相关的库文件

image-20251025210822181

这里只需要简单配置我们的引脚和相关的点灯逻辑。

实现代码

#include "TCS34725.h"
#include <Adafruit_NeoPixel.h>
TCS34725 tcs;
#define PIN        33
#define NUMPIXELS 1
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
 
//相邻 LED 之间的延迟,单位毫秒
#define DELAYVAL 500
void setup(void)
{
   Serial.begin(115200);
   pixels.begin();
   Wire.begin();
   if (!tcs.attach(Wire))
       Serial.println("ERROR: TCS34725 NOT FOUND !!!");

   tcs.integrationTime(33); // ms
   tcs.gain(TCS34725::Gain::X01);

   // 调整 scaling 参数,尝试不同的值
   //tcs.scale(1); // 重点修改这一行

   // set LEDs...
}

void loop(void)
{
   if (tcs.available()) // if current measurement has done
   {
       TCS34725::Color color = tcs.color();
       Serial.print("Color Temp : "); Serial.println(tcs.colorTemperature());
       Serial.print("Lux        : "); Serial.println(tcs.lux());
       Serial.print("R          : "); Serial.println(color.r);
       Serial.print("G          : "); Serial.println(color.g);
       Serial.print("B          : "); Serial.println(color.b);
        for(int i=0; i<NUMPIXELS; i++) { // For each pixel...
           pixels.setPixelColor(i, pixels.Color(color.r, color.g, color.b));
       
           pixels.show();   // Send the updated pixel colors to the hardware.
       }
   }
     pixels.clear(); // Set all pixel colors to 'off'
 
 // The first NeoPixel in a strand is #0, second is 1, all the way up
 // to the count of pixels minus one.
 
}

蓝色

image-20251025212839776

image-20251025212847783

红色

image-20251025212858673




共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]