激光导航

视频图片:
视频介绍:

激光导航

 

哈~~在经过反复的设计电路、找焦点、焊电路板~乃至出错、找错、全部推倒重来之后~~终于基本实现了激光导航~~哈哈哈~~

9CFAEE0D27859B370F0D574527ABA14F_B500_900_500_3809CFAEE0D27859B370F0D574527ABA14F_B500_900_500_380

 

int pinI1=8;//定义I1接口

int pinI2=9;//定义I2接口

int speedpin=11;//定义EA(PWM调速)接口,left

int pinI3=6;//定义I3接口

int pinI4=7;//定义I4接口

int speedpin1=10;//定义EB(PWM调速)接口right

int input=15;//超声波输出端口(发射)连接开发板模拟0

int output=14;//超声波输入端口(接收)连接开发板模拟1

int speed1;//定义左转速

int speed2;//定义右转速

unsigned long time1,time2,oldtime1,oldtime2;

void setup()

{

Serial.begin(9600);

pinMode(pinI1,OUTPUT);

pinMode(pinI2,OUTPUT);

pinMode(speedpin,OUTPUT);

pinMode(pinI3,OUTPUT);

pinMode(pinI4,OUTPUT);

pinMode(speedpin1,OUTPUT);

pinMode(input,INPUT);

pinMode(output,OUTPUT);

pinMode(3,INPUT);

pinMode(4,INPUT);

pinMode(5,INPUT);

pinMode(2,OUTPUT);

speed1=760;

speed2=709;

analogWrite(speedpin,speed1);

analogWrite(speedpin1,speed2);

}

void loop()

{

digitalWrite(pinI4,HIGH);//使直流电机(右)顺时针转

digitalWrite(pinI3,LOW);

digitalWrite(pinI1,HIGH);//使直流电机(左)逆时针转

digitalWrite(pinI2,LOW);

while (digitalRead(3)==LOW)

{

digitalWrite(pinI4,LOW);

digitalWrite(pinI3,HIGH);

digitalWrite(pinI1,HIGH);

digitalWrite(pinI2,LOW);

}

while (digitalRead(4)==LOW)

{

digitalWrite(pinI4,HIGH);//使直流电机(右)顺时针转

digitalWrite(pinI3,LOW);

digitalWrite(pinI1,HIGH);//使直流电机(左)逆时针转

digitalWrite(pinI2,LOW);

}

while (digitalRead(5)==LOW)

{

digitalWrite(pinI4,HIGH);

digitalWrite(pinI3,LOW);

digitalWrite(pinI1,LOW);

digitalWrite(pinI2,HIGH);

}

}

 

激光导航》上有1条评论

  1. Pingback引用通告: BZ编程小组 作品 | BZ编程小组

发表评论

电子邮件地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.