找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2863|回复: 0
收起左侧

实操Arduino+3d打印制造视觉暂留显示器 附源程序

[复制链接]
ID:613370 发表于 2019-9-19 04:58 来自手机 | 显示全部楼层 |阅读模式
制作出来的实物图如下:
09E3B3FB-6372-465D-976A-917A15A30222.jpeg F34769C0-12FA-4FC4-8B4F-F9A33D9E49AE.jpeg 2A841A87-FCA1-4D6C-A81E-B53CD547BE24.jpeg
配件清单
Arduino Nano×1
红外线传感器×1
洞洞板×1
LED 灯×若干
电阻×若干
直流电机×1
电池×1
电线×若干
热熔胶×1
烙铁×1
白纸×1
Arduino IDE(软件)

LED接口方式如下:
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。

代码
/*
* 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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1,0,0,0,0,0,0,1, 1,0,0,0,0,1,0,1, 0,1,1,1,1,1,1,0, 0,0,0,0,0,0,0,1};
int R[] = {1,1,1,1,1,1,1,1, 1,0,0,1,1,0,0,0, 1,0,0,1,0,1,0,0, 1,0,0,1,0,0,1,0, 0,1,1,0,0,0,0,1};
int S[] = {0,1,1,1,0,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,0};
int T[] = {1,0,0,0,0,0,0,0, 1,0,0,0,0,0,0,0, 1,1,1,1,1,1,1,1, 1,0,0,0,0,0,0,0, 1,0,0,0,0,0,0,0};
int U[] = {1,1,1,1,1,1,1,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, 1,1,1,1,1,1,1,0};
int V[] = {1,1,1,1,1,1,0,0, 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 (_);

}
491670F1-FB09-453E-BEE2-DD99751D3435.jpeg
AB5C08DD-3DC8-4222-9383-9801171BDDF4.jpeg
281506BC-980A-4542-921D-295998D496A0.jpeg

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表