最近在搭建led,测试的时候觉得很麻烦,所以自己diy了一个led测试工具这种工具是基于arduino Uno单片机的
把led的8个正极管脚接在单片机的2-9数字端口上,再把LED的8个负极管脚接在一起,然后再接到单片机的gnd口就可以了
下面是接线图:
原代码:
int _ABVAR_1_a;
void setup()
{
Serial.begin(9600);
pinMode( 2 , OUTPUT);
pinMode( 3 , OUTPUT);
pinMode( 4 , OUTPUT);
pinMode( 5 , OUTPUT);
pinMode( 6 , OUTPUT);
pinMode( 7 , OUTPUT);
pinMode( 8 , OUTPUT);
pinMode( 9 , OUTPUT);
}
void loop()
{
Serial.print( "now will start the led test" );
Serial.println();
delay( 3000 );
Serial.print( "3" );
Serial.println();
delay( 1000 );
Serial.print( "2" );
Serial.println();
delay( 1000 );
Serial.print( "1" );
Serial.println();
delay( 1000 );
Serial.print( "start" );
Serial.println();
delay( 1000 );
for (_ABVAR_1_a=1; _ABVAR_1_a<= ( 1000 ); ++_ABVAR_1_a )
{
digitalWrite( 2 , HIGH );
delay( 3000 );
digitalWrite( 2 , LOW );
digitalWrite( 3 , HIGH );
delay( 3000 );
digitalWrite( 3 , LOW );
digitalWrite( 4 , HIGH );
delay( 3000 );
digitalWrite( 4 , LOW );
digitalWrite( 5 , HIGH );
delay( 3000 );
digitalWrite( 5 , LOW );
digitalWrite( 6 , HIGH );
delay( 3000 );
digitalWrite( 6 , LOW );
digitalWrite( 7 , HIGH );
delay( 3000 );
digitalWrite( 7 , LOW );
digitalWrite( 8 , HIGH );
delay( 3000 );
digitalWrite( 8 , LOW );
digitalWrite( 9 , HIGH );
delay( 3000 );
digitalWrite( 2 , HIGH );
digitalWrite( 3 , HIGH );
digitalWrite( 4 , HIGH );
digitalWrite( 5 , HIGH );
digitalWrite( 6 , HIGH );
digitalWrite( 7 , HIGH );
digitalWrite( 8 , HIGH );
delay( 3000 );
digitalWrite( 2 , LOW );
digitalWrite( 3 , LOW );
digitalWrite( 4 , LOW );
digitalWrite( 5 , LOW );
digitalWrite( 6 , LOW );
digitalWrite( 7 , LOW );
digitalWrite( 8 , LOW );
digitalWrite( 9 , LOW );
delay( 1000 );
}
}
用这个工具测led时,LED会一列一列的亮,然后会全部亮起,再灭掉,可以用于led的坏点测试
一开始通电时,LED要过一段时间才开始亮,因为通电时,单片机会给电脑发送信息,需要占用一些时间
演示视频:
030002010052EE53483E5F087B9C8926C614A5-E7B8-9E0D-252D-90FA9B130B42.zip
(2.07 MB, 下载次数: 33)
|