查看: 2523|回复: 2

[视频] 最近写了一个摩尔斯电码,大家看看有什么问题没?

[复制链接]
  • TA的每日心情
    开心
    2023-1-28 16:20
  • 签到天数: 980 天

    连续签到: 1 天

    [LV.10]以坛为家III

    发表于 2016-4-27 15:59:58 | 显示全部楼层 |阅读模式
    分享到:
    1. int pin = 13;

    2. void setup()
    3. {
    4. pinMode(pin, OUTPUT);
    5. }

    6. void loop()
    7. {
    8. fanyi("arduino");
    9. delay(2500);
    10. }


    11. void fanyi(char str1[72]){
    12. int i=0;
    13. while(str1[i]!='\0'){
    14. switch (str1[i]){
    15. case 'a':dot();dash();break;
    16. case 'b':dash();dot();dot();dot();break;
    17. case 'c':dash();dot();dash();dot();break;
    18. case 'd':dash();dot();dot();break;
    19. case 'e':dot();break;
    20. case 'f':dot();dot();dash();dot();break;
    21. case 'g':dash();dash();dot();break;
    22. case 'h':dot();dot();dot();dot();break;
    23. case 'i':dot();dot();break;
    24. case 'j':dot();dash();dash();dash();break;
    25. case 'k':dash();dot();dash();break;
    26. case 'l':dot();dot();dash();dot();dot();break;
    27. case 'm':dash();dash();break;
    28. case 'n':dash();dot();break;
    29. case 'o':dash();dash();dash();break;
    30. case 'p':dot();dash();dash();dot();break;
    31. case 'q':dash();dash();dot();dash();break;
    32. case 'r':dot();dash();dot();break;
    33. case 's':dot();dot();dot();break;
    34. case 't':dash();break;
    35. case 'u':dot();dot();dash();break;
    36. case 'v':dot();dot();dot();dash();break;
    37. case 'w':dot();dash();dash();break;
    38. case 'x':dash();dot();dot();dash();break;
    39. case 'y':dash();dot();dash();dash();break;
    40. case 'z':dash();dash();dot();dot();break;
    41. case '0':dash();dash();dash();dash();dash();break;
    42. case '1':dot();dash();dash();dash();dash();break;
    43. case '2':dot();dot();dash();dash();dash();break;
    44. case '3':dot();dot();dot();dash();dash();break;
    45. case '4':dot();dot();dot();dot();dash();break;
    46. case '5':dot();dot();dot();dot();dot();break;
    47. case '6':dash();dot();dot();dot();dot();break;
    48. case '7':dash();dash();dot();dot();dot();break;
    49. case '8':dash();dash();dash();dot();dot();break;
    50. case '9':dash();dash();dash();dash();dot();break;
    51. }
    52. i++;
    53. delay(250);
    54. }

    55. }


    56. void dot()
    57. {
    58. digitalWrite(pin, HIGH);
    59. delay(250);
    60. digitalWrite(pin, LOW);
    61. delay(250);
    62. }

    63. void dash()
    64. {
    65. digitalWrite(pin, HIGH);
    66. delay(750);
    67. digitalWrite(pin, LOW);
    68. delay(250);
    69. }
    复制代码
    回复

    使用道具 举报

  • TA的每日心情
    慵懒
    2018-3-28 17:24
  • 签到天数: 276 天

    连续签到: 1 天

    [LV.8]以坛为家I

    发表于 2016-4-28 15:17:31 | 显示全部楼层
                      
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    开心
    2023-1-28 16:20
  • 签到天数: 980 天

    连续签到: 1 天

    [LV.10]以坛为家III

     楼主| 发表于 2016-8-22 20:08:23 | 显示全部楼层
    这个板块好没有人气哦。
    回复 支持 反对

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /2 下一条

    手机版|小黑屋|与非网

    GMT+8, 2024-4-18 20:44 , Processed in 0.110497 second(s), 19 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.