“4RGB LED”的版本间的差异

来自Labplus盛思维基百科
跳转至: 导航搜索
(Tangliufeng移动页面RGB LED(4灯)4RGB LED
使用教程
 
(未显示4个用户的25个中间版本)
第1行: 第1行:
 
[[文件:黑色传感器最终版12.20-13.png|350px|缩略图|右]]
 
[[文件:黑色传感器最终版12.20-13.png|350px|缩略图|右]]
 
== 概述 ==
 
== 概述 ==
单板级联4颗RGB灯珠,采用LED专用主控芯片WS2812,支持单总线控制,仅需一根管脚即可控制所有LED,并且模块支持级联控制,可以多个模块同时控制,不占用管脚资源。可实现256级亮度显示,16777216种颜色的全真色彩显示颜色。
+
单板级联4颗RGB灯珠,采用LED专用主控芯片WS2812,支持单总线控制,仅需一根管脚即可控制所有LED,不占用管脚资源。可实现256级亮度显示,16777216种颜色的全真色彩显示颜色。
 
== 技术参数 ==
 
== 技术参数 ==
* 工作电压:3.3Vor5V
+
* 工作电压:VCC 3.3-5V
 
* 通讯方式:单总线控制
 
* 通讯方式:单总线控制
 
* 功 率:0.3W/颗
 
* 功 率:0.3W/颗
第24行: 第24行:
  
 
== 使用教程 ==
 
== 使用教程 ==
=== <small>连接示意图</small> ===
+
=== <font size="3">掌控板</font> ===
=== <small>Arduino示例</small> ===
+
{|
=== <small>MicroPython示例</small> ===
+
|-
 +
| [[文件:4RGB.png |900px|居中|无框]]
 +
|}
 +
 
 +
=== <font size="3">Arduino示例</font> ===
 +
[http://wiki.labplus.cn/images/d/d0/Adafruit_NeoPixel-master.zip RGB LED库文件下载]
 +
 
 +
<pre style="color:blue">
 +
// 程序功能:控制4个RGB灯依次按红绿蓝颜色点亮//
 +
// This is a demonstration on how to use an input device to trigger changes on your neo pixels.
 +
// You should wire a momentary push button to connect from ground to a digital IO pin.  When you
 +
// press the button it will change to a new pixel animation.  Note that you need to press the
 +
// button once to start the first animation!
 +
 
 +
#include "Adafruit_NeoPixel.h"
 +
 
 +
#define PIXEL_PIN    7    // Digital IO pin connected to the NeoPixels.
 +
 
 +
#define PIXEL_COUNT  4    //级联数量
 +
 
 +
// Parameter 1 = number of pixels in strip,  neopixel stick has 8
 +
// Parameter 2 = pin number (most are valid)
 +
// Parameter 3 = pixel type flags, add together as needed:
 +
//  NEO_RGB    Pixels are wired for RGB bitstream
 +
//  NEO_GRB    Pixels are wired for GRB bitstream, correct for neopixel stick
 +
//  NEO_KHZ400  400 KHz bitstream (e.g. FLORA pixels)
 +
//  NEO_KHZ800  800 KHz bitstream (e.g. High Density LED strip), correct for neopixel stick
 +
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
 +
 
 +
void setup() {
 +
  strip.setBrightness(50);    //调亮度
 +
  strip.begin();
 +
  strip.show(); // Initialize all pixels to 'off'
 +
}
 +
 
 +
void loop() {
 +
for(uint16_t num1=0;num1<PIXEL_COUNT;num1++)
 +
{
 +
strip.setPixelColor(num1,255,0,0);  //设置红色
 +
}
 +
strip.show();  //显示
 +
delay(500);
 +
for(uint16_t num1=0;num1<PIXEL_COUNT;num1++)
 +
{
 +
strip.setPixelColor(num1,0,255,0);  //设置绿色
 +
}
 +
strip.show();  //显示
 +
delay(500);
 +
  for(uint16_t num1=0;num1<PIXEL_COUNT;num1++)
 +
{
 +
strip.setPixelColor(num1,0,0,255);    //设置蓝色
 +
}
 +
strip.show();    //显示
 +
delay(500);
 +
 
 +
}
 +
</pre>
 +
 
 +
=== <font size="3">MicroPython示例</font> ===
 +
注意:彩灯位置是从"0"开始计算,如控制N个彩灯,依次为np[0]...np[n-1]
 +
==== <small>连接示意图</small> ====
 +
[[文件:RGB连接图.jpg|600px|居中]]
 
<pre style="color:blue">
 
<pre style="color:blue">
 
from microbit import *
 
from microbit import *
 
import neopixel
 
import neopixel
import math
 
 
display.off()
 
display.off()
  
第53行: 第113行:
 
</pre>
 
</pre>
  
=== <small>图形化示例</small> ===
+
=== <font size="3">图形化示例</font> ===
 +
连接图同上
 +
{|
 +
|-
 +
|[[文件:LED灯 4灯.png|1000px|无框|左]]
 +
|}
 +
 
 +
== 版本历史记录 ==
 +
 
 +
{|  border="1" cellspacing="0" align="left" cellpadding="0" width="60%" style="text-align:center;"
 +
|- style="text-align:center;background-color:#6fa8dc;color:#fffff;"
 +
!width="10%"|Version !!width="15%"| Date !! Note  <small>[+]新增[-]删除[^]修复</small>
 +
|-
 +
| V2.0 || || style="text-align:left"|
 +
|}

2020年6月30日 (二) 16:51的最新版本

黑色传感器最终版12.20-13.png

概述

单板级联4颗RGB灯珠,采用LED专用主控芯片WS2812,支持单总线控制,仅需一根管脚即可控制所有LED,不占用管脚资源。可实现256级亮度显示,16777216种颜色的全真色彩显示颜色。

技术参数

  • 工作电压:VCC 3.3-5V
  • 通讯方式:单总线控制
  • 功 率:0.3W/颗
  • 级联4颗灯珠
  • 灰度等级:256级
  • 16777216种颜色的全真色彩
  • 模块尺寸:24x46x7.5mm

引脚定义

VCC 电源
NC 空脚
DI 控制数据信号输入
GND

使用教程

掌控板

4RGB.png

Arduino示例

RGB LED库文件下载

// 程序功能:控制4个RGB灯依次按红绿蓝颜色点亮//
// This is a demonstration on how to use an input device to trigger changes on your neo pixels.
// You should wire a momentary push button to connect from ground to a digital IO pin.  When you
// press the button it will change to a new pixel animation.  Note that you need to press the
// button once to start the first animation!

#include "Adafruit_NeoPixel.h"

#define PIXEL_PIN    7    // Digital IO pin connected to the NeoPixels.

#define PIXEL_COUNT  4    //级联数量

// Parameter 1 = number of pixels in strip,  neopixel stick has 8
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_RGB     Pixels are wired for RGB bitstream
//   NEO_GRB     Pixels are wired for GRB bitstream, correct for neopixel stick
//   NEO_KHZ400  400 KHz bitstream (e.g. FLORA pixels)
//   NEO_KHZ800  800 KHz bitstream (e.g. High Density LED strip), correct for neopixel stick
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.setBrightness(50);     //调亮度
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
	for(uint16_t num1=0;num1<PIXEL_COUNT;num1++)
	{
		strip.setPixelColor(num1,255,0,0);  //设置红色
	}
	 strip.show();   //显示
	 delay(500);
	 for(uint16_t num1=0;num1<PIXEL_COUNT;num1++)
	{
		strip.setPixelColor(num1,0,255,0);   //设置绿色
	}
	 strip.show();   //显示
	 delay(500);
	  for(uint16_t num1=0;num1<PIXEL_COUNT;num1++)
	{
		strip.setPixelColor(num1,0,0,255);    //设置蓝色
	}
	 strip.show();    //显示
	 delay(500);

}

MicroPython示例

注意:彩灯位置是从"0"开始计算,如控制N个彩灯,依次为np[0]...np[n-1]

连接示意图

RGB连接图.jpg
from microbit import *
import neopixel
display.off()

np=neopixel.NeoPixel(pin0,4)      #pin0为控制引脚,级联4个RGB


while True:
    for i  in range(4):
        np[i]=  (255,0,0)               #设置4颗灯珠显示颜色,颜色为红
    np.show()                           #刷新显示颜色
    for i  in range(4):
        np[i]=  (0,255,0)                #设置4颗灯珠显示颜色,颜色为绿
    sleep(1000)                
    np.show()                           #刷新显示颜色
    for i  in range(4):        
        np[i]=  (0,0,255)               #设置4颗灯珠显示颜色,颜色为蓝
    sleep(1000)
    np.show()                            #刷新显示颜色
    sleep(1000)

   

图形化示例

连接图同上

LED灯 4灯.png

版本历史记录

Version Date Note [+]新增[-]删除[^]修复
V2.0