暑假的第好几周了

这几天学到的东西


1.抢答器

抢答器终于是做好了,虽然只能对两位选手进行比赛…虽然刚开始的时候感觉,看上去,以为不是很难,但是在整个过程还是遇到了许多的问题..

抢答器在硬件连接好了以后进行了和代码的对接,结果出了许多问题…

  • 团队精神欠佳,在张俊松同学的硬件和我写的代码对接以后出现了一些问题(如:板子连上电脑后二号舵机就开始不停命令的转动,LCD屏幕闪动等);此后发生了一些事情浪费了大量的时间,做了许多无用并且重复的事情,由于我比较轴,就对自己出错的地方进行反复排查,最后发现是因为接口改变了而我的代码没有改变,非常的尴尬,然后我就悄悄的把自己的代码改了.
  • 舵机的接口了解的不清楚,在2560板子上,可以运行舵机的接口只有两个,这个知识不知道,耗费了大量的时间来排查这个错误,甚至还问学长了,最后张俊松同学发现了这个知识点,场面一度十分尴尬.

    虽然整个对接的时间花费了一下午,但我认为确实值得的,张俊松和我也都在这过程中了解了彼此,相信我们俩以后的合作花费的时间会更少.


    现在抢答器项目的一些元器件正在运送途中,到了以后抢答器项目就算完整结束了(代码我会贴在最后面,供大家参考.)

2.arduino

在完成抢答器的初代后,有过一段迷茫期,看了数据结构的第二章,敲了敲代码,也觉得无趣,就没有再看下去了,看了看网上的一些算法(回溯等),觉得非常的厉害,然而代码好长,就不是很想看了, 翻了翻操作系统,找到了一个网站的视频,跟着看了几节,之后的内容因为他们的书和我的不一样,也就没有在看了,

3.日常学习两三事

最近这几天和组长在卓越二年级这个教室里学习,看到了学长学姐们做项目的态度与方法,感觉学习了很多,觉得我们这级只有我们两个,有点尴尬,很喜欢他们的这种状态,觉得这样的话进步会比自己一个劲的学有效率,他们也都很搞笑

自己在网上买了一些元器件,想试着尝试下光立方(就是那个8*8*8的一堆LED),当然啦,我怎么可能弄那么叼的东西呢,,,我想先弄个2*2*2的,大概的计划我也已经写出来了,就等着元器件了(^.^)

# include "TM1637.h"
#define CLK 5    //四位数码管  //pins definitions for TM1637 and can be changed to other ports       
#define DIO 6    //四位数码管`
#include <SoftwareSerial.h>
 #include <Servo.h> 
Servo myservo1;  //创建一个舵机控制对象`
Servo myservo2; 
Servo myservo3; 


#define txPin 5

SoftwareSerial LCD = SoftwareSerial(0, txPin);
// since the LCD does not send data back to the Arduino, we should only define the txPin
const int LCDdelay=10;  // conservative, 2 actually works

// wbp: goto with row & column
void lcdPosition(int row, int col) {
  LCD.write(0xFE);   //command flag
  LCD.write((col + row*64 + 128));    //position 
  delay(LCDdelay);
}
void clearLCD(){
  LCD.write(0xFE);   //command flag
  LCD.write(0x01);   //clear command.
  delay(LCDdelay);
}
void backlightOn() {  //s on the backlight
  LCD.write(0x7C);   //command flag for backlight stuff
  LCD.write(157);    //ght level.
  delay(LCDdelay);
}
void backlightOff(){  //s off the backlight
  LCD.write(0x7C);   //command flag for backlight stuff
  LCD.write(128);     //ght level for off.
   delay(LCDdelay);
}
void serCommand(){   //a general function to call the command flag for issuing all other commands   
  LCD.write(0xFE);
}

TM1637 tm1637(CLK,DIO);
int pinmod1=11; //led接口
int pinmod2=12;
int pinmod3=13;
int button1=A1;//led按钮接口
int button2=A2;
int button3=A3;

int b1=0;   //led按钮
int b2=0;
int b3=0;
int button0=A0; //加分按钮接口
int b0=0;
int a=0;  //四位数码管
int b=0;   //四位数码管
int c=0;   //四位数码管
int d=0;   //四位数码管
int k1=0;
int b4=0;
int button4=A4;
int k2=0;
int k3=0;
void setup(){
  pinMode(txPin, OUTPUT);
  LCD.begin(9600);
  backlightOn() ;
  clearLCD();
  lcdPosition(0,0);
     Serial.begin(9600);
     pinMode(button1,INPUT);
      pinMode(button2,INPUT);
      pinMode(button3,INPUT);
       pinMode(button4,INPUT);
     pinMode(pinmod1,OUTPUT);
     pinMode(pinmod2,OUTPUT);
     pinMode(pinmod3,OUTPUT);
     pinMode(button0,INPUT);
     myservo1.attach(8);
     myservo2.attach(9);
     myservo3.attach(10);
     tm1637.init();
     tm1637.set(BRIGHT_DARKEST );      //BRIGHT_TYPICAL = 2,BRIGHT_DARKEST = 0,BRIGHTEST = 7;
}

void loop(){
  b1=analogRead(button1);
  if(b1>1000){
     for(int i=0;i<400;i++){          //i 抢答器led,蜂鸣器显示
         digitalWrite(pinmod1,HIGH);
         delay(1);
         digitalWrite(pinmod1,LOW);
         delay(1);
          }
      for(int j=5;j>=0;j--){          //j 倒计时显示
          d=j;
          tm1637.display(0,a);
          tm1637.display(1,b); 
          tm1637.display(2,c);
          tm1637.display(3,d);
          delay(1000);
          }         
          while(1){
                b0=analogRead(button0);     //k 选手分值
             b4=analogRead(button4);

               if(b0>1000){
                  k1++;
                     clearLCD();
                    LCD.print(k1);
                    delay(5000);
                    clearLCD();
                      break;
                      }
           if(b4>1000){
                  myservo1.write(0);         // 指定舵机转向的角度 
                         delay(700);
                      myservo1.write(90);        // 指定舵机转向的角度
                       delay(1000);                       // 等待15ms让舵机到达指定位置       

                         break;
                        }
          }


      }

      b2=analogRead(button2);
  if(b2>1000){
     for(int i=0;i<400;i++){          //i 抢答器led,蜂鸣器显示
         digitalWrite(pinmod2,HIGH);
         delay(1);
         digitalWrite(pinmod2,LOW);
         delay(1);
          }
      for(int j=5;j>=0;j--){          //j 倒计时显示
          d=j;
          tm1637.display(0,a);
          tm1637.display(1,b); 
          tm1637.display(2,c);
          tm1637.display(3,d);
          delay(1000);
          }
          while(1){
                b0=analogRead(button0);     //k 选手分值
             b4=analogRead(button4);
           if(b0>1000){
                  k2++;   
                  clearLCD();
                    LCD.print(k2);
                    delay(5000);
                    clearLCD();
                      break;
                      }
           if(b4>1000){
             myservo2.write(0);         // 指定舵机转向的角度 
                         delay(700);
                      myservo2.write(90);        // 指定舵机转向的角度
                       delay(1000);                       // 等待15ms让舵机到达指定位置       

                         break;
                        }
          }



      }






      b3=analogRead(button3);
  if(b3>1000){
     for(int i=0;i<400;i++){          //i 抢答器led,蜂鸣器显示
         digitalWrite(pinmod3,HIGH);
         delay(1);
         digitalWrite(pinmod3,LOW);
         delay(1);
          }
      for(int j=5;j>=0;j--){          //j 倒计时显示
          d=j;
          tm1637.display(0,a);
          tm1637.display(1,b); 
          tm1637.display(2,c);
          tm1637.display(3,d);
          delay(1000);
          }


          while(1){
             b0=analogRead(button0);     //k 选手分值
             b4=analogRead(button4); 
          if(b0>1000){
                  k3++;
                     clearLCD();
                    LCD.print(k3);
                    delay(5000);
                    clearLCD();
                      break;
                      }
           if(b4>1000){
                       myservo3.write(0);         // 指定舵机转向的角度 
                         delay(700);
                        myservo3.write(90);        // 指定舵机转向的角度
                       delay(1000);                       // 等待15ms让舵机到达指定位置       

                         break;
                        }
          }




      }

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值