一个不大不小刚刚好的电报
托版主大人的要求,终于在傍晚弄完了,
人脉资源消耗殆尽
先声明感谢:hnyzcj_安徽_教师、粤_Leo、pATAq-江苏;的帮助
视频如下哈.....
http://v.youku.com/v_show/id_XMzU4NjQ4MzkzMg==.html?spm=a2h3j.8428770.3416059.1
在上一个帖子(
https://mc.dfrobot.com.cn/forum.php?mod=viewthread&tid=36959
)中,我发现了一个重要问题
那就是,手势看不懂!手势看不懂!!手势看不懂!!!{:5_144:}
来来来,上图
嗯,还不错,当然如果我有钱买3D打印机的话,我会弄一个比较好的包装
你们一定会有这样的疑问:为什么只有五个键?嗯,原因很简单,主要有以下几点:
1.没有辣么多的按钮
2.UNO板子犯贱贱的不让我弄一堆程序,程序一杂,就开始撒娇——灯连闪个不停,我熬不过它
3.红外遥控的话留给大家思考空间,自己回去试一试
<div align="left">int input1=2;</div>
int input2=3;
int input3=4;
int input4=5;
int input5=6;
int input6=7;
int button=A0;
void setup() {
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();
}
if(val2==LOW){
printB();// put your main code here, to run repeatedly:
}
if(val3==LOW){
printC();// put your main code here, to run repeatedly:
}
if(val4==LOW){
printD();// put your main code here, to run repeatedly:
}
if(val5==LOW){
printE();
}
if(val5==LOW){
tone(button,1047);
delay(1000);
}else{
noTone(button);
}
}// 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(1000);
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(1000);
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(1000);
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(1000);
noTone(button);
}
void printE(){
digitalWrite(13,HIGH);
delay(300);
digitalWrite(13,LOW);
delay(500);
tone(button,1047);
delay(1000);
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(1000);
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(1000);
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(1000);
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(1000);
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(1000);
noTone(button);
}
哈哈
程序是不是很杂{:5_117:}(抽支烟)
其实就是将if语句活用了
这有个莫尔斯电报表,自己可以去对
我的代码后面跟了几个备用的字母,但没有加进去,有兴趣的自己一加就可以了
that‘s all
我也希望你们的看法哦,速回!!!! 顶你起来~ 摩尔斯电报表中有一部分模糊,自己上网搜哈
沙发上护肤{:5_142:}
加油{:5_197:} 加了打印的功能,不错{:5_197:}
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);
}
来个人给我回复下呀,板凳太凉........ ASH腻 发表于 2018-5-7 14:27
顶你起来~
成功上天{:5_197:}
页:
[1]