极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

楼主: eagler8

【Arduino】108种传感器模块系列实验(资料+代码+图形+仿真)

[复制链接]
 楼主| 发表于 2019-9-3 19:09:26 | 显示全部楼层

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-4 06:56:06 | 显示全部楼层
37款传感器与模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止37种的。鉴于本人手头积累了一些传感器和模块,依照实践出真知(一定要动手做)的理念,以学习和交流为目的,这里准备逐一动手试试做实验,不管成功与否,都会记录下来---小小的进步或是搞不定的问题,希望能够抛砖引玉。

【Arduino】108种传感器模块系列实验(资料+代码+图形+仿真)
实验一百零五:12位 WS2812 5050 RGB LED 智能全彩RGB环开发板大环


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-4 07:41:14 | 显示全部楼层

WS2812B
是一种将控制电路和rgb芯片集成在一起的智能控制led光源。5050组件的包装。内部包括智能数字端口数据锁存和信号整形放大驱动电路。还包括精密内部振荡器和12V电压可编程恒流控制部分,有效保证了像素点光色高度一致。数据传输协议采用单NZR通信方式。像素上电复位后,DIN端口接收数据来自控制器,第一个像素收集初始24位数据,然后发送到内部数据锁存器,其他数据由内部信号整形放大电路通过DO端口发送到下一个级联像素进行整形。后对于每个像素的传输,信号要减少24位。像素采用自动整形传输技术,使像素级联数不受信号传输的限制,只取决于信号传输的速度。复位时间>280μs,中断时不会造成误复位,支持较低频率,价格低廉单片机。刷新频率更新到2kHz,画面频率低,高清摄像机无闪烁,提高出色的展示效果。LED具有驱动电压低、环保节能、亮度高、散射角大、一致性好、功率低、寿命长等优点。集成在led上的控制芯片越来越多电路简单,体积小,安装方便。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-4 08:02:55 | 显示全部楼层

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-4 08:05:31 | 显示全部楼层

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-4 08:06:59 | 显示全部楼层

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-4 08:28:11 | 显示全部楼层
主要特点

控制电路和LED共用唯一的电源。

控制电路和RGB芯片集成在5050个组件的封装中,形成完整的可寻址像素。内置信号整形电路,对下一个驱动器进行波形整形后,确保波形不失真累积。

内置电气复位电路和失电复位电路。

三基色各像素可实现256亮度显示,完成16777216色全彩色显示,扫描频率为2kHz。

单线路级联端口传输信号。

任意两点距离不超过3米的传输信号,无任何增加电路。

刷新率为30fps时,层叠数不小于1024像素。以800Kbps的速度发送数据。

灯光颜色一致性高,性价比高。



应用

全彩模块,全彩软灯带。

LED装饰照明,室内外LED视频不规则屏幕。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-4 08:32:23 | 显示全部楼层
几个应用电路

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-4 08:44:27 | 显示全部楼层

名称:12位WS2812智能全彩圆盘LED模块
整体尺寸:直径7cm
芯片:WS2812B(内置于LED)
LED:5050封装RGB全彩高亮
电压:5V
端口:数字
平台:单片机(Arduino 、51单片机等)
控制方式:内置控制芯片,只需一个IO口即可控制

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-4 08:58:49 | 显示全部楼层

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-4 09:34:01 | 显示全部楼层
  1. /*
  2. 【Arduino】108种传感器模块系列实验(资料+代码+图形+仿真)
  3. 实验一百零五:12位 WS2812 5050 RGB LED 智能全彩RGB环开发板大环
  4. 1、安装库:IDE-工具-管理库-搜索Adafruit_NeoPixel-安装
  5. 2、项目:点亮环形LED模块,循环快闪绿色光
  6. 3、接脚:
  7. VCC  → 5V
  8. GND → GND
  9. DI  接  D7
  10. */

  11. #include <Adafruit_NeoPixel.h>

  12. #define PIN 7
  13. #define MAX_LED 12

  14. #define ADD true
  15. #define SUB false

  16. int val = 0;
  17. boolean stat = ADD;

  18. Adafruit_NeoPixel strip = Adafruit_NeoPixel( MAX_LED, PIN, NEO_RGB + NEO_KHZ800 );

  19. void setup()
  20. {
  21.   strip.begin();           
  22.   strip.show();           
  23. }

  24. void loop()
  25. {
  26.   uint8_t i,a=0;                                       
  27.   uint32_t color = strip.Color(255, 100, 0);      
  28.      
  29.   while(a<17)
  30.   {
  31.       for(i=0;i<16;i++)
  32.       {
  33.         if(i==a) strip.setPixelColor(i, color);     
  34.         else strip.setPixelColor(i, 0);            
  35.       }
  36.        strip.show();                                
  37.        delay(20);                                   
  38.        a++;                                         
  39.   }
  40. }
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-4 09:36:43 | 显示全部楼层

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-4 11:34:06 | 显示全部楼层
  1. /*
  2. 【Arduino】108种传感器模块系列实验(资料+代码+图形+仿真)
  3. 实验一百零五:12位 WS2812 5050 RGB LED 智能全彩RGB环开发板大环
  4. 1、安装库:IDE-工具-管理库-搜索Adafruit_NeoPixel-安装
  5. 2、项目:灯环显示彩色
  6. 3、接脚:
  7. VCC  → 5V
  8. GND → GND
  9. DI  接  D7
  10. */

  11. #include <Adafruit_NeoPixel.h>
  12. #ifdef __AVR__
  13. #include <avr/power.h>
  14. #endif

  15. #define PIN 7

  16. // Parameter 1 = number of pixels in strip
  17. // Parameter 2 = Arduino pin number (most are valid)
  18. // Parameter 3 = pixel type flags, add together as needed:
  19. //   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
  20. //   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
  21. //   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
  22. //   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
  23. //   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
  24. Adafruit_NeoPixel strip = Adafruit_NeoPixel(64, PIN, NEO_GRB + NEO_KHZ800);

  25. // IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
  26. // pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
  27. // and minimize distance between Arduino and first pixel.  Avoid connecting
  28. // on a live circuit...if you must, connect GND first.

  29. void setup() {
  30.   // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
  31.   #if defined (__AVR_ATtiny85__)
  32.     if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  33.   #endif
  34.   // End of trinket special code


  35.   strip.begin();
  36.   strip.show(); // Initialize all pixels to 'off'
  37. }

  38. void loop() {
  39.   // Some example procedures showing how to display to the pixels:
  40.   //colorWipe(strip.Color(255, 0, 0), 50); // Red
  41. // colorWipe(strip.Color(0, 255, 0), 50); // Green
  42.   //colorWipe(strip.Color(0, 0, 255), 50); // Blue
  43. //colorWipe(strip.Color(0, 0, 0, 255), 50); // White RGBW
  44.   // Send a theater pixel chase in...
  45. // theaterChase(strip.Color(127, 127, 127), 50); // White
  46.   //theaterChase(strip.Color(127, 0, 0), 50); // Red
  47.   //theaterChase(strip.Color(0, 0, 127), 50); // Blue

  48.   rainbow(20);
  49.   //rainbowCycle(20);
  50.   //theaterChaseRainbow(50);
  51. }

  52. // Fill the dots one after the other with a color
  53. void colorWipe(uint32_t c, uint8_t wait) {
  54.   for(uint16_t i=0; i<strip.numPixels(); i++) {
  55.     strip.setPixelColor(i, c);
  56.     strip.show();
  57.     delay(wait);
  58.   }
  59. }

  60. void rainbow(uint8_t wait) {
  61.   uint16_t i, j;

  62.   for(j=0; j<256; j++) {
  63.     for(i=0; i<strip.numPixels(); i++) {
  64.       strip.setPixelColor(i, Wheel((i+j) & 255));
  65.     }
  66.     strip.show();
  67.     delay(wait);
  68.   }
  69. }

  70. // Slightly different, this makes the rainbow equally distributed throughout
  71. void rainbowCycle(uint8_t wait) {
  72.   uint16_t i, j;

  73.   for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
  74.     for(i=0; i< strip.numPixels(); i++) {
  75.       strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
  76.     }
  77.     strip.show();
  78.     delay(wait);
  79.   }
  80. }

  81. //Theatre-style crawling lights.
  82. void theaterChase(uint32_t c, uint8_t wait) {
  83.   for (int j=0; j<10; j++) {  //do 10 cycles of chasing
  84.     for (int q=0; q < 3; q++) {
  85.       for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
  86.         strip.setPixelColor(i+q, c);    //turn every third pixel on
  87.       }
  88.       strip.show();

  89.       delay(wait);

  90.       for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
  91.         strip.setPixelColor(i+q, 0);        //turn every third pixel off
  92.       }
  93.     }
  94.   }
  95. }

  96. //Theatre-style crawling lights with rainbow effect
  97. void theaterChaseRainbow(uint8_t wait) {
  98.   for (int j=0; j < 256; j++) {     // cycle all 256 colors in the wheel
  99.     for (int q=0; q < 3; q++) {
  100.       for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
  101.         strip.setPixelColor(i+q, Wheel( (i+j) % 255));    //turn every third pixel on
  102.       }
  103.       strip.show();

  104.       delay(wait);

  105.       for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
  106.         strip.setPixelColor(i+q, 0);        //turn every third pixel off
  107.       }
  108.     }
  109.   }
  110. }

  111. // Input a value 0 to 255 to get a color value.
  112. // The colours are a transition r - g - b - back to r.
  113. uint32_t Wheel(byte WheelPos) {
  114.   WheelPos = 255 - WheelPos;
  115.   if(WheelPos < 85) {
  116.     return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  117.   }
  118.   if(WheelPos < 170) {
  119.     WheelPos -= 85;
  120.     return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  121.   }
  122.   WheelPos -= 170;
  123.   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  124. }  
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-4 11:58:25 | 显示全部楼层
  1. /*
  2. 【Arduino】108种传感器模块系列实验(资料+代码+图形+仿真)
  3. 实验一百零五:12位 WS2812 5050 RGB LED 智能全彩RGB环开发板大环
  4. 1、安装库:IDE-工具-管理库-搜索Adafruit_NeoPixel-安装
  5. 2、项目:逐个点亮环形彩色LED
  6. 3、接脚:
  7. VCC  → 5V
  8. GND → GND
  9. DI  接  D7
  10. */

  11. #include <FastLED.h>
  12. #define LED_PIN     7
  13. #define NUM_LEDS    12

  14. CRGB leds[NUM_LEDS];

  15. void setup() {
  16.   FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
  17. }

  18. void loop() {
  19.   leds[0] = CRGB(255, 0, 0);
  20.   FastLED.show();
  21.   delay(500);  
  22.   
  23.   leds[1] = CRGB(0, 255, 0);
  24.   FastLED.show();
  25.   delay(500);
  26.   
  27.   leds[2] = CRGB(0, 0, 255);
  28.   FastLED.show();
  29.   delay(500);
  30.   
  31.   leds[3] = CRGB(150, 0, 255);
  32.   FastLED.show();
  33.   delay(500);
  34.   
  35.   leds[4] = CRGB(255, 200, 20);
  36.   FastLED.show();
  37.   delay(500);
  38.   
  39.   leds[5] = CRGB(85, 60, 180);
  40.   FastLED.show();
  41.   delay(500);
  42.   
  43.   leds[6] = CRGB(150, 255, 20);
  44.   FastLED.show();
  45.   delay(500);

  46.   leds[7] = CRGB(0, 50, 255);
  47.   FastLED.show();
  48.   delay(500);

  49.   leds[8] = CRGB(255, 255, 0);
  50.   FastLED.show();
  51.   delay(500);  
  52.   
  53.   leds[9] = CRGB(20, 25, 255);
  54.   FastLED.show();
  55.   delay(500);
  56.   
  57.   leds[10] = CRGB(255, 0, 20);
  58.   FastLED.show();
  59.   delay(500);
  60.   
  61.   leds[11] = CRGB(50, 0, 55);
  62.   FastLED.show();
  63.   delay(500);
  64. }
复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-9-4 12:56:58 | 显示全部楼层
  1. /*
  2. 【Arduino】108种传感器模块系列实验(资料+代码+图形+仿真)
  3. 实验一百零五:12位 WS2812 5050 RGB LED 智能全彩RGB环开发板大环
  4. 1、安装库:IDE-工具-管理库-搜索Adafruit_NeoPixel-安装
  5. 2、项目:红蓝色快扫——这里第一个“for”循环点亮所有12个蓝色LED,
  6. 从第一个LED到最后一个LED,延迟40毫秒。 下一个“for”循环再
  7. 次点亮所有12个LED,但这次是红色,反之,从最后一个LED到第一个LED。
  8. 3、接脚:
  9. VCC  → 5V
  10. GND → GND
  11. DI  接  D7
  12. */

  13. #include <FastLED.h>
  14. #define LED_PIN     7
  15. #define NUM_LEDS    12

  16. CRGB leds[NUM_LEDS];

  17. void setup() {
  18.   FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
  19. }

  20. void loop() {
  21.   for (int i = 0; i <= 11; i++) {
  22.     leds[i] = CRGB ( 0, 0, 255);
  23.     FastLED.show();
  24.     delay(60);
  25.   }
  26.   for (int i = 11; i >= 0; i--) {
  27.     leds[i] = CRGB ( 255, 0, 0);
  28.     FastLED.show();
  29.     delay(40);
  30.   }
  31. }
复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-5-21 01:37 , Processed in 0.048475 second(s), 16 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表