用Arduino Mega2560控制一个8X8的点阵,显示“祝我生日快乐”以及心型图案,代码是仿照参考的文章写的(复制粘贴的),参考文章链接Arduino 8x8点阵怦然心动 - CSDN博客 和用ArduinoUNO控制8×8点阵LED显示“祝大家节日快乐”-Arduino中文社区 - Powered by Discuz!(谢谢原作者)新手,请多指教!
我用的点阵型号是1088BS(共阳),引脚用的是22~37这16个引脚(引脚多,随意浪)。参考链接:LD-1088BS_百度文库
int Row[] = {29, 26, 28, 35, 32, 33, 25, 23};//行
int Column[] = {30, 24, 34, 22, 31, 36, 27, 37};//列
unsigned char bigheart[8][8] = //'大心'
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 1, 1, 0, 0, 1, 1, 0,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1, 1, 0,
0, 0, 1, 1, 1, 1, 0, 0,
0, 0, 0, 1, 1, 0, 0, 0,
};
unsigned char smallheart[8][8] = //'小心'
{
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, 1, 1, 1, 1, 1, 1, 0,
0, 1, 1, 1, 1, 1, 1, 0,
0, 0, 1, 1, 1, 1, 0, 0,
0, 0, 0, 1, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
unsigned char zhu[8][8] = //'祝'
{
1, 0, 0, 1, 1, 1, 1, 1,
0, 1, 0, 1, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1,
0, 1, 1, 0, 1, 0, 1, 0,
1, 1, 0, 0, 1, 0, 1, 0,
0, 1, 0, 0, 1, 0, 1, 0,
0, 1, 0, 0, 1, 0, 1, 0,
0, 1, 0, 1, 0, 0, 1, 1,
};
unsigned char wo[8][8] = //'我'
{
0, 0, 1, 0, 1, 0, 1, 0,
0, 1, 1, 0, 1, 0, 0, 1,
1, 0, 1, 0, 1, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1,
0, 0, 1, 1, 0, 1, 0, 0,
0, 1, 1, 0, 0, 1, 1, 0,
1, 0, 1, 0, 1, 1, 0, 0,
0, 1, 1, 0, 0, 0, 1, 1,
};
unsigned char sheng[8][8] = //'生'
{
0, 1, 0, 0, 1, 0, 0, 0,
0, 1, 0, 0, 1, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1,
1, 0, 0, 0, 1, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 1, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1,
};
unsigned char ri[8][8] = //'日'
{
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 1, 1, 1, 1, 1, 0,
0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 1, 1, 1, 1, 1, 0,
0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 1, 0, 0, 0, 1, 0,
0, 0, 1, 1, 1, 1, 1, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
unsigned char kuai[8][8] = //'快'
{
0, 1, 0, 0, 1, 0, 0, 0,
0, 1, 0, 0, 1, 0, 0, 0,
1, 1, 0, 1, 1, 1, 1, 0,
0, 1, 1, 0, 1, 0, 1, 0,
0, 1, 1, 1, 1, 1, 1, 1,
0, 1, 0, 0, 1, 0, 0, 0,
0, 1, 0, 1, 0, 1, 0, 0,
0, 1, 1, 0, 0, 0, 1, 1,
};
unsigned char le[8][8] = //'乐'
{
0, 0, 0, 0, 0, 0, 0, 1,
0, 1, 1, 1, 1, 1, 1, 0,
0, 1, 0, 0, 1, 0, 0, 0,
0, 1, 1, 1, 1, 1, 1, 1,
0, 0, 0, 0, 1, 0, 0, 0,
0, 0, 1, 0, 1, 0, 1, 0,
0, 1, 0, 0, 1, 0, 0, 1,
0, 0, 0, 1, 1, 0, 0, 0,
};
void setup() {
// put your setup code here, to run once:
for(int i = 0; i < 8; i++)
{
pinMode(Row[i], OUTPUT);//输出模式
pinMode(Column[i], OUTPUT);
}
}
void loop() {
// put your main code here, to run repeatedly:
for(int i = 0; i< 100; i++)
{
Display(zhu);
}
for(int i = 0; i< 100; i++)
{
Display(wo);
}
for(int i = 0; i< 100; i++)
{
Display(sheng);
}
for(int i = 0; i< 100; i++)
{
Display(ri);
}
for(int i = 0; i< 100; i++)
{
Display(kuai);
}
for(int i = 0; i< 100; i++)
{
Display(le);
}
for(int i = 0; i< 100; i++)
{
Display(bigheart);
}
for(int i = 0; i < 100; i++)
{
Display(smallheart);
}
for(int i = 0; i< 100; i++)
{
Display(bigheart);
}
for(int i = 0; i < 100; i++)
{
Display(smallheart);
}
}
void Display(unsigned char lattice[8][8])//显示函数
{
for(int r = 0; r < 8; r++)
{
digitalWrite(Row[r], LOW);
for(int c = 0; c < 8; c++)
{
digitalWrite(Column[c], lattice[r][c]);
}
delay(1);
Clear();
}
}
void Clear()//清除函数
{
for(int i = 0; i < 8; i++)
{
digitalWrite(Row[i], HIGH);
digitalWrite(Column[i], LOW);
}
}