看到jxs做的那个遥控密码引爆装置,觉得深受启发,尤其是那个蜂鸣器。让我想起了从前玩CS的时代。正好最近做实验需要安全的起爆方式,所以就用现有的模块编写了个Arduino程序来定时控制继电器。为了追求更好的效果,做出了类似于CS中C4那个嘀嘀声和灯闪逐渐变快最后引爆的效果。(注:仅继电器模拟,并未连接和谐物演示)
从左至右为1234继电器,小灯也分别对应。假想123控制和谐物,4为倒计时指示,用继电器开合产生的哒哒声代替蜂鸣器。
视频↓(手机拍摄,略有不清晰)
点击此处查看视频Arduino源代码
int _ABVAR_1_;
int _ABVAR_2_;
int _ABVAR_3_;
int _ABVAR_4_;
void setup()
{
pinMode( 8 , OUTPUT);
pinMode( 7 , OUTPUT);
pinMode( 6 , OUTPUT);
pinMode( 5 , OUTPUT);
}
void loop()
{
digitalWrite( 5 , HIGH );
digitalWrite( 6 , HIGH );
digitalWrite( 7 , HIGH );
digitalWrite( 8 , HIGH );
for (_ABVAR_1_=0; _ABVAR_1_< ( 20 ); ++_ABVAR_1_ )
{
delay( 900 );
digitalWrite( 8 , LOW );
delay( 100 );
digitalWrite( 8 , HIGH );
}
for (_ABVAR_2_=0; _ABVAR_2_< ( 20 ); ++_ABVAR_2_ )
{
delay( 400 );
digitalWrite( 8 , LOW );
delay( 100 );
digitalWrite( 8 , HIGH );
}
for (_ABVAR_3_=0; _ABVAR_3_< (12 ); ++_ABVAR_3_ )
{
delay( 150 );
digitalWrite( 8 , LOW );
delay( 100 );
digitalWrite( 8 , HIGH );
}
for (_ABVAR_3_=0; _ABVAR_3_< (10 ); ++_ABVAR_3_ )
{
delay( 100 );
digitalWrite( 8 , LOW );
delay( 100 );
digitalWrite( 8 , HIGH );
}
digitalWrite( 5 , LOW );
digitalWrite( 8 , LOW );
digitalWrite( 7 , LOW );
digitalWrite( 6 , LOW );
delay( 1000 );
digitalWrite( 6 , HIGH );
digitalWrite( 5 , HIGH );
digitalWrite( 7 , HIGH );
digitalWrite( 8 , HIGH );
delay( 250 );
digitalWrite( 5 , LOW );
delay( 250 );
digitalWrite( 6 , LOW );
delay( 250 );
digitalWrite( 7 , LOW );
delay( 250 );
digitalWrite( 8 , LOW );
delay( 250 );
digitalWrite( 5 , HIGH );
delay( 250 );
digitalWrite( 6 , HIGH );
delay( 250 );
digitalWrite( 7 , HIGH );
delay( 250 );
digitalWrite( 8 , HIGH );
}
200字以内,仅用于支线交流,主线讨论请采用回复功能。