8651浏览
查看: 8651|回复: 4

[进阶] 一个不大不小刚刚好的电报

[复制链接]
一个不大不小刚刚好的电报图1

托版主大人的要求,终于在傍晚弄完了,

人脉资源消耗殆尽

先声明感谢:hnyzcj_安徽_教师、粤_Leo、pATAq-江苏;的帮助

视频如下哈.....


在上一个帖子(

https://mc.dfrobot.com.cn/forum.php?mod=viewthread&tid=36959

)中,我发现了一个重要问题

那就是,手势看不懂!手势看不懂!!手势看不懂!!!


来来来,上图

一个不大不小刚刚好的电报图2一个不大不小刚刚好的电报图3一个不大不小刚刚好的电报图4


嗯,还不错,当然如果我有钱买3D打印机的话,我会弄一个比较好的包装

你们一定会有这样的疑问:为什么只有五个键?嗯,原因很简单,主要有以下几点:

1.没有辣么多的按钮
2.UNO板子犯贱贱的不让我弄一堆程序,程序一杂,就开始撒娇——灯连闪个不停,我熬不过它
3.红外遥控的话留给大家思考空间,自己回去试一试
  1. <div align="left">int input1=2;</div>
  2. int input2=3;
  3. int input3=4;
  4. int input4=5;
  5. int input5=6;
  6. int input6=7;
  7. int button=A0;
  8. void setup() {
  9.   pinMode(13,OUTPUT);// put your setup code here, to run once:
  10.   pinMode(input1,INPUT);
  11.   pinMode(input2,INPUT);
  12.   pinMode(input3,INPUT);
  13.   pinMode(input4,INPUT);
  14.   pinMode(input5,INPUT);
  15.   pinMode(input6,INPUT);
  16.   pinMode(button,OUTPUT);
  17. }
  18. void loop() {
  19.   int val1=digitalRead(input1);
  20.   int val2=digitalRead(input2);
  21.   int val3=digitalRead(input3);
  22.   int val4=digitalRead(input4);
  23.   int val5=digitalRead(input5);
  24.   int val6=digitalRead(input6);
  25.   if(val1==LOW){
  26.     printA();
  27.   }
  28.   if(val2==LOW){
  29.     printB();// put your main code here, to run repeatedly:
  30.   }
  31.   if(val3==LOW){
  32.     printC();// put your main code here, to run repeatedly:
  33.   }
  34.   if(val4==LOW){
  35.     printD();// put your main code here, to run repeatedly:
  36.   }
  37.   if(val5==LOW){
  38.     printE();
  39.   }
  40.   if(val5==LOW){
  41.     tone(button,1047);
  42.     delay(1000);
  43.   }else{
  44.     noTone(button);
  45.   }
  46.   }// put your main code here, to run repeatedly:
  47.   void printA(){
  48.     digitalWrite(13,HIGH);
  49.     delay(300);
  50.     digitalWrite(13,LOW);
  51.     delay(500);
  52.     digitalWrite(13,HIGH);
  53.     delay(1000);
  54.     digitalWrite(13,LOW);
  55. tone(button,1047);
  56. delay(1000);
  57. noTone(button);
  58. }
  59. void printB(){
  60.   digitalWrite(13,HIGH);
  61.     delay(1000);
  62.     digitalWrite(13,LOW);
  63.     delay(500);
  64.     digitalWrite(13,HIGH);
  65.     delay(300);
  66.     digitalWrite(13,LOW);
  67.     delay(500);
  68.     digitalWrite(13,HIGH);
  69.     delay(300);
  70.     digitalWrite(13,LOW);
  71.     delay(500);
  72.     digitalWrite(13,HIGH);
  73.     delay(300);
  74.     digitalWrite(13,LOW);
  75.     tone(button,1047);
  76.     delay(1000);
  77.     noTone(button);
  78. }
  79. void printC(){
  80.    digitalWrite(13,HIGH);
  81.     delay(1000);
  82.     digitalWrite(13,LOW);
  83.     delay(500);
  84.     digitalWrite(13,HIGH);
  85.     delay(300);
  86.     digitalWrite(13,LOW);
  87.     delay(500);
  88.     digitalWrite(13,HIGH);
  89.     delay(1000);
  90.     digitalWrite(13,LOW);
  91.     delay(500);
  92.     digitalWrite(13,HIGH);
  93.     delay(300);
  94.     digitalWrite(13,LOW);
  95.   tone(button,1047);
  96.   delay(1000);
  97.   noTone(button);
  98. }
  99. void printD(){
  100.   digitalWrite(13,HIGH);
  101.     delay(1000);
  102.     digitalWrite(13,LOW);
  103.     delay(500);
  104.     digitalWrite(13,HIGH);
  105.     delay(300);
  106.     digitalWrite(13,LOW);
  107.     delay(500);
  108.     digitalWrite(13,HIGH);
  109.     delay(300);
  110.     digitalWrite(13,LOW);
  111.     delay(500);
  112.   tone(button,1047);
  113.   delay(1000);
  114.   noTone(button);
  115. }
  116. void printE(){
  117.   digitalWrite(13,HIGH);
  118.     delay(300);
  119.     digitalWrite(13,LOW);
  120.     delay(500);
  121.     tone(button,1047);
  122.     delay(1000);
  123.     noTone(button);
  124. }
  125. void printF(){
  126.   digitalWrite(13,HIGH);
  127.     delay(300);
  128.     digitalWrite(13,LOW);
  129.     delay(500);
  130.     digitalWrite(13,HIGH);
  131.     delay(300);
  132.     digitalWrite(13,LOW);
  133.     delay(500);
  134.     digitalWrite(13,HIGH);
  135.     delay(1000);
  136.     digitalWrite(13,LOW);
  137.     delay(500);
  138.     digitalWrite(13,HIGH);
  139.     delay(300);
  140.     digitalWrite(13,LOW);
  141.     tone(button,1047);
  142.     delay(1000);
  143.     noTone(button);
  144. }
  145. void printG(){
  146.   digitalWrite(13,HIGH);
  147.     delay(1000);
  148.     digitalWrite(13,LOW);
  149.     delay(500);
  150.     digitalWrite(13,HIGH);
  151.     delay(1000);
  152.     digitalWrite(13,LOW);
  153.     delay(500);
  154.     digitalWrite(13,HIGH);
  155.     delay(300);
  156.     digitalWrite(13,LOW);
  157.     tone(button,1047);
  158.     delay(1000);
  159.     noTone(button);
  160. }
  161. void printH(){
  162.   digitalWrite(13,HIGH);
  163.     delay(300);
  164.     digitalWrite(13,LOW);
  165.     delay(500);
  166.      digitalWrite(13,HIGH);
  167.     delay(300);
  168.     digitalWrite(13,LOW);
  169.     delay(500);
  170.     digitalWrite(13,HIGH);
  171.     delay(300);
  172.     digitalWrite(13,LOW);
  173.     delay(500);
  174.     digitalWrite(13,HIGH);
  175.     delay(300);
  176.     digitalWrite(13,LOW);
  177.     tone(button,1047);
  178.     delay(1000);
  179.     noTone(button);
  180. }
  181. void printI(){
  182.   digitalWrite(13,HIGH);
  183.     delay(300);
  184.     digitalWrite(13,LOW);
  185.     delay(500);
  186.      digitalWrite(13,HIGH);
  187.     delay(300);
  188.     digitalWrite(13,LOW);
  189.     tone(button,1047);
  190.     delay(1000);
  191.     noTone(button);
  192. }
  193. void printJ(){
  194.   digitalWrite(13,HIGH);
  195.     delay(1000);
  196.     digitalWrite(13,LOW);
  197.     delay(500);
  198.      digitalWrite(13,HIGH);
  199.     delay(300);
  200.     digitalWrite(13,LOW);
  201.       digitalWrite(13,HIGH);
  202.     delay(1000);
  203.     digitalWrite(13,LOW);
  204.     delay(500);
  205.     tone(button,1047);
  206.     delay(1000);
  207.     noTone(button);
  208. }
复制代码

哈哈

程序是不是很杂(抽支烟)

其实就是将if语句活用了

这有个莫尔斯电报表,自己可以去对

一个不大不小刚刚好的电报图5

我的代码后面跟了几个备用的字母,但没有加进去,有兴趣的自己一加就可以了

that‘s all

我也希望你们的看法哦,速回!!!!

ASH腻  管理员

发表于 2018-5-7 14:27:16

顶你起来~
回复

使用道具 举报

1973742214  高级技师
 楼主|

发表于 2018-5-5 22:30:30

摩尔斯电报表中有一部分模糊,自己上网搜哈
沙发上护肤
加油
回复

使用道具 举报

1973742214  高级技师
 楼主|

发表于 2018-5-6 11:25:46

加了打印的功能,不错
[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]
来个人给我回复下呀,板凳太凉........
回复

使用道具 举报

1973742214  高级技师
 楼主|

发表于 2018-5-12 20:23:59


成功上天
回复

使用道具 举报

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

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail