• CoCube显示测试笔记


    数字量LED显示案例:


    cocube测试led刷新

    代码如下: 

    1. for(DELAYVAL=1;DELAYVAL<10;DELAYVAL++)
    2. {
    3. // The first NeoPixel in a strand is #0, second is 1, all the way up
    4. // to the count of pixels minus one.
    5. for(int i=0; i// For each pixel...
    6. // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
    7. // Here we're using a moderately bright green color:
    8. pixels.setPixelColor(i, pixels.Color(1, 0, 0));
    9. pixels.show(); // Send the updated pixel colors to the hardware.
    10. delay(DELAYVAL); // Pause before next pass through loop
    11. }
    12. for(int i=0; i// For each pixel...
    13. // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
    14. // Here we're using a moderately bright green color:
    15. pixels.setPixelColor(i, pixels.Color(0, 1, 0));
    16. pixels.show(); // Send the updated pixel colors to the hardware.
    17. delay(DELAYVAL); // Pause before next pass through loop
    18. }
    19. for(int i=0; i// For each pixel...
    20. // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
    21. // Here we're using a moderately bright green color:
    22. pixels.setPixelColor(i, pixels.Color(0, 0, 1));
    23. pixels.show(); // Send the updated pixel colors to the hardware.
    24. delay(DELAYVAL); // Pause before next pass through loop
    25. }
    26. for(int i=0; i// For each pixel...
    27. // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
    28. // Here we're using a moderately bright green color:
    29. pixels.setPixelColor(i, pixels.Color(1, 1, 0));
    30. pixels.show(); // Send the updated pixel colors to the hardware.
    31. delay(DELAYVAL); // Pause before next pass through loop
    32. }
    33. for(int i=0; i// For each pixel...
    34. // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
    35. // Here we're using a moderately bright green color:
    36. pixels.setPixelColor(i, pixels.Color(0, 1, 1));
    37. pixels.show(); // Send the updated pixel colors to the hardware.
    38. delay(DELAYVAL); // Pause before next pass through loop
    39. }
    40. for(int i=0; i// For each pixel...
    41. // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
    42. // Here we're using a moderately bright green color:
    43. pixels.setPixelColor(i, pixels.Color(1, 0, 1));
    44. pixels.show(); // Send the updated pixel colors to the hardware.
    45. delay(DELAYVAL); // Pause before next pass through loop
    46. }
    47. for(int i=0; i// For each pixel...
    48. // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
    49. // Here we're using a moderately bright green color:
    50. pixels.setPixelColor(i, pixels.Color(1, 1, 1));
    51. pixels.show(); // Send the updated pixel colors to the hardware.
    52. delay(DELAYVAL); // Pause before next pass through loop
    53. }
    54. }

    注释为原版程序,未作修改。 


    简单解释一下:

    // NeoPixel Ring 简单草图 (c) 2013 Shae Erisson
    // 在 GPLv3 许可下发布以匹配其余的
    // Adafruit NeoPixel 库

    参考:Adafruit_NeoPixel

    // 在设置 NeoPixel 库时,设置有多少像素
    // 以及使用哪个引脚发送信号。 请注意,对于旧版 NeoPixel
    // 删除可能需要更改的第三个参数——参见
    // strandtest 示例以获取有关可能值的更多信息。

    NUMPIXELS是LED数量,8*8一共64个。

    DELAYVAL是刷新时延,1ms-9ms。

    pixels.setPixelColor(i, pixels.Color(1, 0, 0));

    分别为RGB颜色显示。

    pixels.Color(1, 0, 0) 红色亮度1

    pixels.Color(0, 1, 0) 绿色亮度1

    pixels.Color(0, 0, 1) 蓝色亮度1

    pixels.Color(255, 0, 0) 红色亮度255

    pixels.Color(0, 255, 0) 绿色亮度255

    pixels.Color(0, 0, 255) 蓝色亮度255

     // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255


  • 相关阅读:
    Webpack demo + npm run dev,localhost:8080 提示 Cannot GET/
    【集训DAY N】词典【暴力】【字典树】
    响应式系统与react笔记 | 青训营笔记
    一个Python中优雅的数据分块方法
    锐捷交换机系统安装与升级
    pytorch从0开始安装
    RabbitMQ 消息中间件
    ETF轮动+RSRS择时,加上卡曼滤波:年化48.41%,夏普比1.89
    centos7磁盘挂载及目录扩容
    java计算机毕业设计美食推荐管理系统源码+系统+mysql数据库+lw文档
  • 原文地址:https://blog.csdn.net/ZhangRelay/article/details/126217999