8252| 4
|
[进阶] 一个不大不小刚刚好的电报 |
托版主大人的要求,终于在傍晚弄完了, 人脉资源消耗殆尽 先声明感谢:hnyzcj_安徽_教师、粤_Leo、pATAq-江苏;的帮助 视频如下哈..... 在上一个帖子( https://mc.dfrobot.com.cn/forum.php?mod=viewthread&tid=36959 )中,我发现了一个重要问题 那就是,手势看不懂!手势看不懂!!手势看不懂!!! 来来来,上图 嗯,还不错,当然如果我有钱买3D打印机的话,我会弄一个比较好的包装 你们一定会有这样的疑问:为什么只有五个键?嗯,原因很简单,主要有以下几点: 1.没有辣么多的按钮 2.UNO板子犯贱贱的不让我弄一堆程序,程序一杂,就开始撒娇——灯连闪个不停,我熬不过它 3.红外遥控的话留给大家思考空间,自己回去试一试
哈哈 程序是不是很杂(抽支烟) 其实就是将if语句活用了 这有个莫尔斯电报表,自己可以去对 我的代码后面跟了几个备用的字母,但没有加进去,有兴趣的自己一加就可以了 that‘s all 我也希望你们的看法哦,速回!!!! |
加了打印的功能,不错 [mw_shl_code=cpp,true]int input1=2; int input2=3; int input3=4; int input4=5; int input5=6; int input6=7; int button=A0; void setup() { Serial.begin(9600); pinMode(13,OUTPUT);// put your setup code here, to run once: pinMode(input1,INPUT); pinMode(input2,INPUT); pinMode(input3,INPUT); pinMode(input4,INPUT); pinMode(input5,INPUT); pinMode(input6,INPUT); pinMode(button,OUTPUT); } void loop() { int val1=digitalRead(input1); int val2=digitalRead(input2); int val3=digitalRead(input3); int val4=digitalRead(input4); int val5=digitalRead(input5); int val6=digitalRead(input6); if(val1==LOW){ printA(); Serial.print(".___"); Serial.println("A"); } if(val2==LOW){ printB(); Serial.print("___..."); Serial.println("B");// put your main code here, to run repeatedly: } if(val3==LOW){ printC(); Serial.print("___.___."); Serial.println("C");// put your main code here, to run repeatedly: } if(val4==LOW){ printD(); Serial.print("___.."); Serial.println("D");// put your main code here, to run repeatedly: } if(val5==LOW){ printE(); Serial.print("___"); Serial.println("E"); } }// put your main code here, to run repeatedly: void printA(){ digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(1000); digitalWrite(13,LOW); tone(button,1047); delay(100); noTone(button); } void printB(){ digitalWrite(13,HIGH); delay(1000); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); tone(button,1047); delay(100); noTone(button); } void printC(){ digitalWrite(13,HIGH); delay(1000); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(1000); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); tone(button,1047); delay(100); noTone(button); } void printD(){ digitalWrite(13,HIGH); delay(1000); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); delay(500); tone(button,1047); delay(100); noTone(button); } void printE(){ digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); delay(500); tone(button,1047); delay(100); noTone(button); } void printF(){ digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(1000); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); tone(button,1047); delay(100); noTone(button); } void printG(){ digitalWrite(13,HIGH); delay(1000); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(1000); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); tone(button,1047); delay(100); noTone(button); } void printH(){ digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); tone(button,1047); delay(100); noTone(button); } void printI(){ digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); tone(button,1047); delay(100); noTone(button); } void printJ(){ digitalWrite(13,HIGH); delay(1000); digitalWrite(13,LOW); delay(500); digitalWrite(13,HIGH); delay(300); digitalWrite(13,LOW); digitalWrite(13,HIGH); delay(1000); digitalWrite(13,LOW); delay(500); tone(button,1047); delay(100); noTone(button); } [/mw_shl_code] 来个人给我回复下呀,板凳太凉........ |
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed