首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Arduino Adafruit NeoPixel发光二极管矩阵工作不正常

Arduino Adafruit NeoPixel发光二极管矩阵工作不正常
EN

Stack Overflow用户
提问于 2022-09-09 20:18:15
回答 1查看 110关注 0票数 0

我是Arduino开发的新手,尝试在8x8 LED矩阵中显示字母表,但模拟不起作用

有一个字母的代码运行良好,下面的示例中我做错了什么?

如何调试代码以及在tinkercad模拟中添加打印语句的方法?

代码语言:javascript
运行
复制
#include <Adafruit_NeoPixel.h>

#define PIN 4 // input pin Neopixel is attached to

#define NUMPIXELS 64 // number of neopixels in strip

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

const int8_t alphas[26][NUMPIXELS] = {
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
:
: // alphabet values
:
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
    {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};

uint8_t i = 0;

void setup()
{
  pixels.begin();
}

void loop()
{
  delay(2500);
  if (i == 26)
  {
    i = 0;
  }

  for (uint8_t j = 0; j < 64; j++)
  {
    int8_t pix = alphas[i][j];
    if (pix == 1)
    {
      pixels.setPixelColor(j, pixels.Color(255, 0, 0));
    }
    else
    {
      pixels.setPixelColor(j, pixels.Color(255, 255, 255));
    }
  }
  pixels.show();
  ++i;
}

EN

回答 1

Stack Overflow用户

发布于 2022-09-09 21:11:34

在安装函数中,您应该具有:

代码语言:javascript
运行
复制
void setup()
{
  pixels.begin();
  pixels.show();
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73667121

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档