我是Arduino开发的新手,尝试在8x8 LED矩阵中显示字母表,但模拟不起作用
有一个字母的代码运行良好,下面的示例中我做错了什么?
如何调试代码以及在tinkercad模拟中添加打印语句的方法?
#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;
}
发布于 2022-09-09 21:11:34
在安装函数中,您应该具有:
void setup()
{
pixels.begin();
pixels.show();
}
https://stackoverflow.com/questions/73667121
复制相似问题