人眼在观察景物时,光信号传入大脑神经,需经过一段短暂的时间,光的作用结束后,视觉形象并不立即消失,这种残留的视觉称“后像”,也被称为是“视觉暂留”。
人眼每秒处理的图像不超过 10-12 个。当一系列图像很快的连续性的滚动时,就会让我们产生幻觉,感觉画面在动。这也是制作动画电影的基本原则。
本期给大家带来一款别出心裁的 LED 显示器,用 Arduino、电机和一排 LED 制作的视觉暂留显示器。
是不是很酷呢,接下来我们先来看一段视频,看看是如何制作的吧。
https://v.qq.com/x/page/g0863ltrhnt.html
POV_DISPLAY.ino
[5769 Bytes at 2019-04-22, 97 次下载]
Case.stl
[220484 Bytes at 2019-04-22, 96 次下载]
Motor+Mount.stl
[218484 Bytes at 2019-04-22, 81 次下载]
Arduino Nano×1
红外线传感器×1
洞洞板×1
LED 灯×若干
电阻×若干
直流电机×1
电池×1
电线×若干
热熔胶×1
烙铁×1
白纸×1
Arduino IDE(软件)
3D 打印部分主要分为旋转支架和固定底座两个部分。
所需 3D 打印的 STL 文件请在项目文件库中下载。
3D 部件打印完毕后,就可以进入操作环节了。
1、剪取一块洞洞板,大小与旋转支架部分相匹配。
2、安装 LED 灯,我使用八个红色的 LED 灯。关于灯的颜色,你可以自由选择。
3、将所有 LED 灯的负极端口都焊接到洞洞板上。
4、添加电阻,防止 LED 灯因电压(5V)过高而烧坏。我使用 220ohm 的电阻,将每个电阻焊接到每个 LED 灯的正极。
5、将跳线电缆连接到电阻的另一个脚上。
连接接口的方式如下:
LED0:Nano 的 D2 。
LED1: Nano 的 D3 。
LED2: Nano 的 D4 。
LED3: Nano 的 D5 。
LED4: Nano 的 D6 。
LED5: Nano 的 D7 。
LED6: Nano 的 D8 。
LED7: Nano 的 D9 。
负极为:Nano 的 Ground 。
将直流电机安装到固定底座上并通电。
我们需要一个点作为文本读写开始的起点。在固定底座下面粘贴一块白纸块作为起点,红外线传感器能检测到这张白纸块。
如果改变白纸的位置,那么文本显示的位置也将随之发生改变。
红外线传感器与 Nano 连接方式如下 :
GND:Nano 的 GND。
Vin: Nano 的 5V。
Out:Nano 的 D10。
1、连接电源,给 Arduino Nano 通电。
2、将 Arduino Nano 安装到旋转的部件中。
3、将旋转部件安装到固定底座上。
/*
* This Code demonstrates
* LED POV DISPLAY
*
* Components used
* 1) Arduino Nano
* 2) DC motor
* 3) LEDs
* 4) IR sensor
* 5) Battery
* 6) Wire
*
* Connect leds to 2 to 9 digital pin of Nano
* Connect IR sensor out pin to 10 digital pin of Nano
*
* code written by Palak Mehta on March 29,2019
*/
////////////////////////design a pattern of display the number and alphabates////////////////////////////////
int NUMBER9[]={1,1,1,1,0,0,0,1, 1,0,0,1,0,0,0,1, 1,0,0,1,0,0,0,1, 1,0,0,1,0,0,0,1, 1,1,1,1,1,1,1,1};
int NUMBER8[]={0,1,1,0,1,1,1,0, 1,0,0,1,0,0,0,1, 1,0,0,1,0,0,0,1, 1,0,0,1,0,0,0,1, 0,1,1,0,1,1,1,0};
int NUMBER7[]={1,0,0,0,0,0,0,0, 1,0,0,0,1,0,0,0, 1,0,0,0,1,0,0,0, 1,0,0,1,1,1,1,1, 1,1,1,0,1,0,0,0};
int NUMBER6[]={1,1,1,1,1,1,1,1, 1,0,0,0,1,0,0,1, 1,0,0,0,1,0,0,1, 1,0,0,0,1,0,0,1, 1,0,0,0,1,1,1,1};
int NUMBER5[]={1,1,1,1,1,0,0,1, 1,0,0,0,1,0,0,1, 1,0,0,0,1,0,0,1, 1,0,0,0,1,0,0,1, 1,0,0,0,1,1,1,1};
int NUMBER2[]= {1,0,0,0,0,0,1,1, 1,0,0,0,0,1,0,1, 1,0,0,0,1,0,0,1, 1,0,0,1,0,0,0,1, 0,1,1,0,0,0,0,1};
int NUMBER1[]= {0,0,1,0,0,0,0,0, 0,1,0,0,0,0,0,0, 1,1,1,1,1,1,1,1, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0};
int NUMBER0[]= {1,1,1,1,1,1,1,1, 1,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,1, 1,0,0,0,0,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, 0,0,0,0,0,0,1,0, 0,0,0,0,0,0,0,1, 0,0,0,0,0,0,1,0, 1,1,1,1,1,1,0,0};
int W[] = {1,1,1,1,1,1,1,1, 0,0,0,0,0,0,1,0, 0,0,0,0,0,1,0,0, 0,0,0,0,0,0,1,0, 1,1,1,1,1,1,1,1};
int X[] = {1,1,0,0,0,0,1,1, 0,0,1,0,0,1,0,0, 0,0,0,1,1,0,0,0, 0,0,1,0,0,1,0,0, 1,1,0,0,0,0,1,1};
int Y[] = {1,1,0,0,0,0,0,0, 0,0,1,0,0,0,0,0, 0,0,0,1,1,1,1,1, 0,0,1,0,0,0,0,0, 1,1,0,0,0,0,0,0};
int Z[] = {1,0,0,0,0,1,1,1, 1,0,0,0,1,0,0,1, 1,0,0,1,0,0,0,1, 1,0,1,0,0,0,0,1, 1,1,0,0,0,0,0,1};
int* alpha[]= {A,B,C,D,E,F,G,H,I,J,K,L,M,N};//,T,U,V,W,X,Y,Z};
int letterSpace;
int delayTime;
#define IR_pin 10
void setup()
{
Serial.begin(9600);
pinMode(IR_pin,INPUT);
for( int i = 2; i<10 ;i++ ) // setting the ports of the leds to OUTPUT
{
pinMode(i, OUTPUT);
}
letterSpace =4;// defining the space between the letters (ms)
delayTime =1;// defining the time dots appear (ms)
}
void printLetter(int letter[])
{
int y;
// printing the first y row of the letter
for (y=0; y<8; y++)
{
digitalWrite(y+2, letter[y]);
}
delay(delayTime);
// printing the second y row of the letter
for (y=0; y<8; y++)
{
digitalWrite(y+2, letter[y+8]);
}
delay(delayTime);
// printing the third y row of the letter
for (y=0; y<8; y++)
{
digitalWrite(y+2, letter[y+16]);
}
delay(delayTime);
for(y = 0; y<8; y++) {
digitalWrite(y+2, letter[y+24]);
}
delay(delayTime);
for(y = 0; y<8; y++) {
digitalWrite(y+2, letter[y+32]);
}
delay(delayTime);
// printing the space between the letters
for (y=0; y<8; y++)
{
digitalWrite(y+2, 0);
}
delay(letterSpace);
}
void loop()
{
if(digitalRead(IR_pin)==LOW)
{
printLetter (P);
printLetter (O);
printLetter (V);
printLetter (_);
printLetter (_);
printLetter (D);
printLetter (I);
printLetter (S);
printLetter (P);
printLetter (L);
printLetter (A);
printLetter (Y);
printLetter (_);
}
代码文件可以在项目文件库下载。
当红外线传感器检测到白纸时,LED 灯就开始发光并显示出视觉暂留的效果。由于视觉暂留原理,开关特定 LED 灯时,会显现出不同的图像相互重叠而形成的文字。
是不是简单又有趣?