查看: 2229 | 回复: 34
Arduino Dot Matrix 新人帖
[复制链接]
小弟最近玩了 Dot Matrix .. 基本的操作会了一点点.. 看见 LED 发亮仿佛是看见baby 出世一样..
小弟乱打了一个 x = y 的线 其他的图画就不会了
废话少说了看图,看编制再来研究
不过小弟还是不会明白很多东西.. 小弟的编制很差..const int row[8] = {
2, 3, 4, 5, 9, 8, 7, 6 };
const int col[8] = {
10, 11, 12, 13, 16, 17,18, 19 };
int x = 0;
int y = 0;
void setup() {
for(int thisPin = 0; thisPin < 8; thisPin++ ) {
pinMode(col[thisPin],OUTPUT);
pinMode(row[thisPin],OUTPUT);
digitalWrite(col[thisPin],LOW);
digitalWrite(col[thisPin],LOW);
}
}
void clr(){
digitalWrite(row[x],LOW);
digitalWrite(col[x],LOW);
}
void loop() {
for(int a = 0; a < 8; a++){
x = a;
y = a;
digitalWrite(row[x],HIGH);
digitalWrite(col[y],HIGH);
clr();
}
}
复制代码 想问问各位高手有什么方法好介绍吗 ?
小弟想要用来写 ABC , 画自己要的图片 一只金鱼.. 一个爱心.. 可是要怎么编制就想不到了..
发表于 20-8-2013 04:12 PM
|
显示全部楼层
楼主
|
发表于 20-8-2013 10:53 PM
|
显示全部楼层
楼主
|
发表于 20-8-2013 11:36 PM
|
显示全部楼层
西门庆33 发表于 20-8-2013 04:12 PM
Arduino网站不是有 example吗?
http://playground.arduino.cc/Main/DirectDriveLEDMatrix
大哥真的不好意思一直来烦你..
想问问下
FrequencyTimer2::disable();
// Set refresh rate (interrupt timeout period)
FrequencyTimer2::setPeriod(2000);
// Set interrupt routine to be called
FrequencyTimer2::setOnOverflow(display);
disable = 吧 pin 11 正常运作...
setPeriod(2000) = interrupt timeout period 其实不是很明白什么意思 大大可以帮帮小弟一下吗
setOnOverflow() = 这个更加不明白了 大大.....
setPattern(pattern);
#define F { \
{0, 0, 1, 1, 1, 1, 1, 0}, \
{0, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 1, 1, 1, 1, 0, 0}, \
{0, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 1, 0, 0, 0, 0, 0} \
}
{\{}\{}\{}\{}\} <-- 这样的写法是什么意思 为什么他要这样排的 .....
byte patterns[numPatterns][8][8] = {
H,E,L,L,O,o0o1,o0o2
};
那个 byte 我真的不明白是什么来的.. 看了
A byte stores an 8-bit unsigned number, from 0 to 255. 啊啊啊啊啊啊... 是不是说 byte 和 int 是一样的 分别就是 byte 0~ 255 int -32,768 ~ 32,768
他是怎样 turn LED On 的啊 T.T 电子白痴就是白痴
大大有什么方式学会吗..
#include <FrequencyTimer2.h>
#define SPACE { \
{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, 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, 0, 0, 0, 0, 0, 0} \
}
#define H { \
{0, 1, 0, 0, 0, 0, 1, 0}, \
{0, 1, 0, 0, 0, 0, 1, 0}, \
{0, 1, 0, 0, 0, 0, 1, 0}, \
{0, 1, 1, 1, 1, 1, 1, 0}, \
{0, 1, 0, 0, 0, 0, 1, 0}, \
{0, 1, 0, 0, 0, 0, 1, 0}, \
{0, 1, 0, 0, 0, 0, 1, 0}, \
{0, 1, 0, 0, 0, 0, 1, 0} \
}
#define E { \
{0, 1, 1, 1, 1, 1, 1, 0}, \
{0, 1, 0, 0, 0, 0, 0, 0}, \
{0, 1, 0, 0, 0, 0, 0, 0}, \
{0, 1, 1, 1, 1, 1, 1, 0}, \
{0, 1, 0, 0, 0, 0, 0, 0}, \
{0, 1, 0, 0, 0, 0, 0, 0}, \
{0, 1, 0, 0, 0, 0, 0, 0}, \
{0, 1, 1, 1, 1, 1, 1, 0} \
}
#define L { \
{0, 1, 0, 0, 0, 0, 0, 0}, \
{0, 1, 0, 0, 0, 0, 0, 0}, \
{0, 1, 0, 0, 0, 0, 0, 0}, \
{0, 1, 0, 0, 0, 0, 0, 0}, \
{0, 1, 0, 0, 0, 0, 0, 0}, \
{0, 1, 0, 0, 0, 0, 0, 0}, \
{0, 1, 0, 0, 0, 0, 0, 0}, \
{0, 1, 1, 1, 1, 1, 1, 0} \
}
#define O { \
{0, 0, 0, 1, 1, 0, 0, 0}, \
{0, 0, 1, 0, 0, 1, 0, 0}, \
{0, 1, 0, 0, 0, 0, 1, 0}, \
{0, 1, 0, 0, 0, 0, 1, 0}, \
{0, 1, 0, 0, 0, 0, 1, 0}, \
{0, 1, 0, 0, 0, 0, 1, 0}, \
{0, 0, 1, 0, 0, 1, 0, 0}, \
{0, 0, 0, 1, 1, 0, 0, 0} \
}
#define F { \
{0, 0, 1, 1, 1, 1, 1, 0}, \
{0, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 1, 1, 1, 1, 0, 0}, \
{0, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 1, 0, 0, 0, 0, 0} \
}
#define o0o1 { \
{0, 0, 0, 0, 0, 1, 0, 0}, \
{0, 0, 0, 0, 1, 0, 1, 0}, \
{0, 0, 0, 0, 1, 0, 1, 0}, \
{0, 0, 0, 0, 1, 0, 1, 0}, \
{0, 0, 1, 1, 1, 0, 1, 1}, \
{0, 1, 1, 0, 1, 0, 1, 0}, \
{1, 0, 1, 0, 1, 0, 1, 0}, \
{1, 0, 1, 0, 1, 0, 1, 0} \
}
#define o0o2 { \
{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, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0}, \
{1, 0, 0, 0, 0, 0, 0, 0}, \
{1, 0, 0, 0, 0, 0, 0, 0}, \
{1, 0, 0, 0, 0, 0, 0, 0} \
}
byte col = 0;
byte leds[8][8];
// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)
int pins[17]= {-1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 19, 18, 17, 16};
// col[xx] of leds = pin yy on led matrix
int cols[8] = {pins[1], pins[2], pins[3], pins[4], pins[5], pins[6], pins[7], pins[8]};
// row[xx] of leds = pin yy on led matrix
int rows[8] = {pins[9], pins[10], pins[11], pins[12], pins[13], pins[14], pins[15], pins[16]};
const int numPatterns = 8;
byte patterns[numPatterns][8][8] = {
H,E,L,L,O,o0o1,o0o2
};
int pattern = 0;
void setup() {
// sets the pins as output
for (int i = 1; i <= 16; i++) {
pinMode(pins[i], OUTPUT);
}
// set up cols and rows
for (int i = 1; i <= 8; i++) {
digitalWrite(cols[i - 1], HIGH);
}
for (int i = 1; i <= 8; i++) {
digitalWrite(rows[i - 1], HIGH);
}
clearLeds();
// Turn off toggling of pin 11
FrequencyTimer2::disable();
// Set refresh rate (interrupt timeout period)
FrequencyTimer2::setPeriod(2000);
// Set interrupt routine to be called
FrequencyTimer2::setOnOverflow(display);
setPattern(pattern);
}
void loop() {
pattern = ++pattern % numPatterns;
slidePattern(pattern, 60);
}
void clearLeds() {
// Clear display array
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
leds[i][j] = 0;
}
}
}
void setPattern(int pattern) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
leds[i][j] = patterns[pattern][i][j];
}
}
}
void slidePattern(int pattern, int del) {
for (int l = 0; l < 8; l++) {
for (int i = 0; i < 7; i++) {
for (int j = 0; j < 8; j++) {
leds[j][i] = leds[j][i+1];
}
}
for (int j = 0; j < 8; j++) {
leds[j][7] = patterns[pattern][j][0 + l];
}
delay(del);
}
}
// Interrupt routine
void display() {
digitalWrite(cols[col], LOW); // Turn whole previous column off
col++;
if (col == 8) {
col = 0;
}
for (int row = 0; row < 8; row++) {
if (leds[col][7 - row] == 1) {
digitalWrite(rows[row], HIGH); // Turn on this led
}
else {
digitalWrite(rows[row], LOW); // Turn off this led
}
}
digitalWrite(cols[col], HIGH); // Turn whole column on at once (for equal lighting times)
} 复制代码
楼主
|
发表于 20-8-2013 11:55 PM
|
显示全部楼层
发表于 21-8-2013 07:40 PM
|
显示全部楼层
angels1026 发表于 20-8-2013 11:36 PM
大哥真的不好意思一直来烦你..
想问问下
FrequencyTimer2::disable();FrequencyTimer2::setPeriod(2000); 设定间隔时间为2000 microseconds (2 millisecond, 0.002 seconds)。我猜想你以为它是2000 ms(2 seconds) FrequencyTimer2::setOnOverflow(display); 复制代码 如果你知道FrequencyTimer2::setPeriod(2000) 是 2 millisecond后,可能你已经明白了。那是每2 millisecond运行display程序,相等于另一个loop在运行
disable = 吧 pin 11 正常运作.. 如果没有添加这行指令,每一个时钟(clock cycle)都会toggle pin11{\{}\{}\{}\{}\} <-- 这样的写法是什么意思 为什么他要这样排的 复制代码 我没有注意到这个 \ ,应该不需要的吧?你试下把 \ 除去,看可以正常操作吗?
\ 是一个escape command,通常后在\ 的后面还有一个字母。比如“//,/*,/r,/n”
这个
const int numPatterns = 6;
byte patterns[numPatterns][8][8] = {
H,E,L,L,O,SPACE
}; 与这个
void setPattern(int pattern) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
leds[j] = patterns[pattern][j];
}
}
}
我和你一样,还没有搞清楚,因为setPattern只在setup里运行了一次,之後再也没有运行了。
请给我一些时间消化
pattern = ++pattern % 8; 那个 pattern 前面的++ 怎么要放在前面的
应该是pattern = ++pattern % 6
pattern=++pattern 与 pattern=pattern+1是同样的。每运行一次, pattern 将会加一
%(modulo) 是要取得余数
0 % 6=0
1 %6 =1
2 % 6=2
3 %6 =3
4 % 6=4
5 %6 =5
6 % 6=0
7 %6 =1
所以patern的值时常介于0和5之间,与(for i=0, i<=5, i++相似)
如果同时可以使用byte与int,那当然选择使用byte。因为微控制器的资源有限,RAM很小,Arduino UNO 只有2KB RAM。反观我们的个人电脑,都是1GB以上。
本帖最后由 西门庆33 于 21-8-2013 07:46 PM 编辑
楼主
|
发表于 23-8-2013 01:02 PM
|
显示全部楼层
西门庆33 发表于 21-8-2013 07:40 PM
设定间隔时间为2000 microseconds (2 millisecond, 0.002 seconds)。我猜想你以为它是2000 ms(2 seconds) ...
大哥.. 至于这个const int numPatterns = 8;
byte patterns[numPatterns][8][8] = {
H,E,L,L,O,o0o1,o0o2
}; 复制代码 byte patterns[][][] =
把它化成我能明白的就是 byte pattern [][][] = {
{ {},{},{},{},{},{},{},{} },
{ {},{},{},{},{},{},{},{} },
{ {},{},{},{},{},{},{},{} },
{ {},{},{},{},{},{},{},{} },
{ {},{},{},{},{},{},{},{} },
{ {},{},{},{},{},{},{},{} },
{ {},{},{},{},{},{},{},{} },
{ {},{},{},{},{},{},{},{} },
} 复制代码 所以 numPattern = pattern 的 array 有几个 member .... 如果是 Hello 就有 5 个
[5][][] 接下来两个 就 H 的 member [][] 就放那个 # define 那边的 array .. 应该是这样吧.. 如果有出请打小弟
本帖最后由 angels1026 于 23-8-2013 01:03 PM 编辑
发表于 23-8-2013 05:10 PM
|
显示全部楼层
angels1026 发表于 23-8-2013 01:02 PM
大哥.. 至于这个byte patterns[][][] =
把它化成我能明白的就是所以 numPattern = pattern 的 array 有 ...
这个byte patterns[numPatterns][8][8] 没问题,也不过是一般的multidimensional array,容易明白。我不明白之处是它被下面的代码搞乱了
void setPattern(int pattern) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
leds[j] = patterns[pattern][j];
}
}
}
经你提醒那个#define,我现在弄清零了。原来是之前没有看清楚代码,我一直以为是这样declare array
#define HELLO {
{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, 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, 0, 0, 0, 0, 0, 0}
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 0} ,
{0, 0, 0, 1, 1, 0, 0, 0},
{0, 0, 1, 0, 0, 1, 0, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 1, 0, 0, 0, 0, 1, 0},
{0, 0, 1, 0, 0, 1, 0, 0},
{0, 0, 0, 1, 1, 0, 0, 0}
}
其实我比较少用上面方式(二进制)declare font。我喜爱用下面方式(十六进制)declare font,与上面的(SPACE,H,E,L,O) declare一样,但只用一个dimension array,且代码较短unsigned char font[40] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Char 000 (space)
0x66, 0x66, 0x66, 0x7E, 0x66, 0x66, 0x66, 0x00, // Char 072 (H)
0x7E, 0x60, 0x60, 0x78, 0x60, 0x60, 0x7E, 0x00, // Char 069 (E)
0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7E, 0x00, // Char 076 (L)
0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, // Char 079 (O)
}
复制代码 本帖最后由 西门庆33 于 23-8-2013 05:12 PM 编辑
楼主
|
发表于 23-8-2013 10:34 PM
|
显示全部楼层
西门庆33 发表于 23-8-2013 05:10 PM
这个byte patterns[numPatterns][8][8] 没问题,也不过是一般的multidimensional array,容易明白。我不明 ...
大哥... FrequencyTimer2::setOnOverflow(display); 这个是什么来的
还有就是他怎样用 二进制 来点亮 LED
楼主
|
发表于 23-8-2013 10:40 PM
|
显示全部楼层
发表于 25-8-2013 10:39 AM
|
显示全部楼层
angels1026 发表于 23-8-2013 10:34 PM
大哥... FrequencyTimer2::setOnOverflow(display); 这个是什么来的
还有就是他怎样用 二进制 来 ... FrequencyTimer2::setOnOverflow(display); 这个是什么来的 FrequencyTimer2::setOnOverflow() 是一个timer中断,必须与FrequencyTimer2::setPeriod()配合
FrequencyTimer2::setPeriod(2000);
FrequencyTimer2::setOnOverflow(display);
上面代码是每0.002秒(2000 microseconds)执行一次display程序
使用上面的方阵来解释。col会一直不停的顺序从col 1扫描至col 8,每一次col更换,将会扫描row 1至row 8。因此每次只有一粒led点亮或息。此动作必须不停的运行,且速度非常快,称之为refresh rate 或者FPS(frame per second)
例:
#define E { \
{0, 1, 1, 1, 1, 1, 1, 0}, \
{0, 1, 0, 0, 0, 0, 0, 0}, \
{0, 1, 0, 0, 0, 0, 0, 0}, \
{0, 1, 1, 1, 1, 1, 1, 0}, \
{0, 1, 0, 0, 0, 0, 0, 0}, \
{0, 1, 0, 0, 0, 0, 0, 0}, \
{0, 1, 0, 0, 0, 0, 0, 0}, \
{0, 1, 1, 1, 1, 1, 1, 0} \
}
每次col更换,row1 至 row8不停的扫描
for (int row = 0; row < 8; row++) {
if (leds[col][7 - row] == 1) {
digitalWrite(rows[row], LOW); // Turn on this led
}
else {
digitalWrite(rows[row], HIGH); // Turn off this led
}
}
当col=1 (注意:array是从0算起的)
row 1 = 0 ,运行digitalWrite(rows[row], LOW) => digitalWrite(rows[0], LOW)
row 2 = 0 ,运行digitalWrite(rows[row], LOW) => digitalWrite(rows[1], LOW)
row 3 = 0 ,运行digitalWrite(rows[row], LOW) => digitalWrite(rows[2], LOW)
row 4 = 0 ,运行digitalWrite(rows[row], LOW) => digitalWrite(rows[3], LOW)
row 5 = 0 ,运行digitalWrite(rows[row], LOW) => digitalWrite(rows[4], LOW)
row 6 = 0 ,运行digitalWrite(rows[row], LOW) => digitalWrite(rows[5], LOW)
row 7 = 0 ,运行digitalWrite(rows[row], LOW) => digitalWrite(rows[6], LOW)
row 8 = 0 ,运行digitalWrite(rows[row], LOW) => digitalWrite(rows[7], LOW)
当col=2
row 1 = 1 ,运行digitalWrite(rows[row], HIGH)
row 2 = 1 ,运行digitalWrite(rows[row], HIGH)
row 3 = 1 ,运行digitalWrite(rows[row], HIGH)
row 4 = 1 ,运行digitalWrite(rows[row], HIGH)
row 5 = 1 ,运行digitalWrite(rows[row], HIGH)
row 6 = 1 ,运行digitalWrite(rows[row], HIGH)
row 7 = 1 ,运行digitalWrite(rows[row], HIGH)
row 8 = 1 ,运行digitalWrite(rows[row], HIGH)
当col=3
row 1 = 1 ,运行digitalWrite(rows[row], HIGH) => digitalWrite(rows[0], HIGH )
row 2 = 0 ,运行digitalWrite(rows[row],LOW) => digitalWrite(rows[1], LOW)
row 3 = 0 ,运行digitalWrite(rows[row],LOW) => digitalWrite(rows[2], LOW)
row 4 = 1 ,运行digitalWrite(rows[row], HIGH) => digitalWrite(rows[3], HIGH )
row 5 = 0 ,运行digitalWrite(rows[row],LOW) => digitalWrite(rows[4], LOW)
row 6 = 0 ,运行digitalWrite(rows[row],LOW) => digitalWrite(rows[5], LOW)
row 7 = 0 ,运行digitalWrite(rows[row],LOW) => digitalWrite(rows[6], LOW)
row 8 = 1 ,运行digitalWrite(rows[row], HIGH) => digitalWrite(rows[7], HIGH )
由此类推
发表于 25-8-2013 10:48 AM
|
显示全部楼层
angels1026 发表于 23-8-2013 10:40 PM
if (leds[col][7 - row] == 1) {
为什么要 7- row 的
我猜想他要从row 7开始,然後倒数扫描。意思是从下面扫描至上面。
楼主
|
发表于 25-8-2013 09:41 PM
|
显示全部楼层
西门庆33 发表于 25-8-2013 10:48 AM
我猜想他要从row 7开始,然後倒数扫描。意思是从下面扫描至上面。
大哥这个是根据我明白的东西写出来的... 我不贪心.. 只是想要一个 Fxxx 的 F 而已...#include <FrequencyTimer2.h>
#define F { \
{0, 0, 1, 1, 1, 1, 1, 0}, \
{0, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 1, 1, 1, 1, 0, 0}, \
{0, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 1, 0, 0, 0, 0, 0}, \
{0, 0, 1, 0, 0, 0, 0, 0} \
}
int pins[17] = { -1,2,3,4,5,6,7,8,9,10,11,12,13,19,18,17,16};
int cols[8] = {pins[1], pins[2], pins[3], pins[4], pins[5], pins[6], pins[7], pins[8]};
int rows[8] = {pins[9], pins[10], pins[11], pins[12], pins[13], pins[14], pins[15], pins[16] };
int row = 0;
byte LED [8][8];
byte col = 0;
byte patterns[8][8] = F ;
void setup(){
for(int i = 0; i < 16; i++){
pinMode(pins[i],OUTPUT);
}
FrequencyTimer2::disable();
FrequencyTimer2::setPeriod(1000);
FrequencyTimer2::setOnOverflow(display);
}
void loop(){
setPattern();
display();
}
void setPattern(){
for(int x = 0; x < 8; x++ ){
for(int y = 0; y < 8; y++){
LED[x][y] = patterns[x][y];
}
}
}
void display(){
digitalWrite(cols[col],LOW);
col++;
if(col == 8){
col = 0;
}
for(int row = 0; row < 8; row++){
if(LED[col][7- row] ==1){
digitalWrite(rows[row],HIGH);
}
else{
digitalWrite(rows[row],LOW);
}
}
digitalWrite(cols[col],HIGH);
}
复制代码 F 出现在眼前了... 泪水都流了出来... 可是...
VIDEO
楼主
|
发表于 25-8-2013 09:46 PM
|
显示全部楼层
西门庆33 发表于 25-8-2013 10:48 AM
我猜想他要从row 7开始,然後倒数扫描。意思是从下面扫描至上面。
发表于 26-8-2013 12:12 AM
|
显示全部楼层
angels1026 发表于 25-8-2013 09:41 PM
大哥这个是根据我明白的东西写出来的... 我不贪心.. 只是想要一个 Fxxx 的 F 而已...F 出现在眼前了... 泪 ...
你的display在FrequencyTimer2::setOnOverflow(display)里执行了,loop里就不需要了。
既然只是一个字符,#define F与byte patterns[8][8] = F 可以省了。
LED更改为
byte LED[8][8] = {
{0, 0, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 1, 0, 0, 0, 0, 0}
}
setPattern()
与
void setPattern(){
for(int x = 0; x < 8; x++ ){
for(int y = 0; y < 8; y++){
LED[x][y] = patterns[x][y];
}
}
}
也可以省了
最后连所有FrequencyTimer2都省了,loop里只需要一display呼叫就行了。
void loop(){
display();
}
楼主
|
发表于 26-8-2013 12:22 AM
|
显示全部楼层
西门庆33 发表于 26-8-2013 12:12 AM
你的display在FrequencyTimer2::setOnOverflow(display)里执行了,loop里就不需要了。
既然只是一个字 ...
yes... 不过 LED 不亮 = = 没有 frequencytimer 加入 LED 很暗...
不过加多一个 delay(1) 就可以了 实验完成... 研究下一步...
最后给我发现到了... frequencytimer 自动运行 (display)
void loop 不需要写任何东西.. Fxxx 的 F 就可以出现了
楼主
|
发表于 26-8-2013 12:23 AM
|
显示全部楼层
西门庆33 发表于 26-8-2013 12:12 AM
你的display在FrequencyTimer2::setOnOverflow(display)里执行了,loop里就不需要了。
既然只是一个字 ...
那么简单的东西却花了那么多时间来消化... 看来 MCU 不适合我玩
发表于 27-8-2013 11:03 PM
|
显示全部楼层
angels1026 发表于 26-8-2013 12:23 AM
那么简单的东西却花了那么多时间来消化... 看来 MCU 不适合我玩
之前你没有学过编程,现在刚开始学习,已经到这地部了。算是尤秀生了。加油!
楼主
|
发表于 28-8-2013 12:39 AM
|
显示全部楼层
发表于 29-8-2013 09:56 PM
|
显示全部楼层
angels1026 发表于 28-8-2013 12:39 AM
上两个礼拜手痒痒跑去 TI 公司的网页.. 随便乱填 要求 sample, 今天早上真的送来了.. 有点感动..特地从 U ...
你是使用公司名下申请 的吗?之前很多马来西亚人溅用了此方便,TI 公司不允许(只限马来西亚) 个人申请 了。现在开放了吗?
本周最热论坛帖子