資源簡介
我自己寫的簡單五路尋跡程序,五路尋跡黑白線沒有占空比。程序會比較簡單,使用者必須自己修改程序后,才能用。
代碼片段和文件信息
/*#include
sbit?z_q1=P1^0;
sbit?z_q2=P1^1;
sbit?z_h1=P1^2;
sbit?z_h2=P1^3;
sbit?y_q1=P1^4;
sbit?y_q2=P1^5;
sbit?y_h1=P1^6;
sbit?y_h2=P1^7;
void?main()
{
while(1)
{
z_q1=0;?????
z_q2=1;
z_h1=0;
z_h2=1;
y_q1=0;
y_q2=1;
y_h1=0;
y_h2=1;
}
}*/
#include
#define?uint?unsigned?int
void?delay(uint);
//*****************************************************
sbit?out1=P2^0;?????//五路循跡傳感器第一三五
sbit?out2=P2^1;
sbit?out3=P2^2;
sbit?out4=P2^3;
sbit?out5=P2^4;
sbit?z_q1=P1^0;
sbit?z_q2=P1^1;
sbit?z_h1=P1^2;
sbit?z_h2=P1^3;
sbit?y_q1=P1^4;
sbit?y_q2=P1^5;
sbit?y_h1=P1^6;
sbit?y_h2=P1^7;
//*****************************************************
void?forward(void)?????????????//向前走
{
z_q1=0;
z_q2=1;
z_h1=0;
z_h2=1;
y_q1=0;
y_q2=1;
y_h1=0;
y_h2=1;
}
void?reverse(void)????????????//向后走
{
z_q1=1;
z_q2=0;
z_h1=1;
z_h2=0;
y_q1=1;
y_q2=0;
y_h1=1;
y_h2=0;
}
/*void?stop(void)????????????????//停止
{
z_q1=0;
z_q2=0;
z_h1=0;
z_h2=0;
y_q1=0;
y_q2=0;
y_h1=0;
y_h2=0;
}*/
void?Right_turn(void)?????//右轉,右側車輪靜止
{
z_q1=0;
z_q2=1;
z_h1=0;
z_h2=1;
y_q1=0;
y_q2=0;
y_h1=0;
y_h2=0;
}
void?Lift_turn(void)?????//左轉,左側車輪靜止
{
z_q1=0;
z_q2=0;
z_h1=0;
z_h2=0;
y_q1=0;
y_q2=1;
y_h1=0;
y_h2=1;
}
void?Lift_place(void)????//左轉,原地
{
z_q1=1;
z_q2=0;
z_h1=1;
z_h2=0;
y_q1=0;
y_q2=1;
y_h1=0;
y_h2=1;
}
void?Right_place(void)????//右轉,原地
{
z_q1=0;
z_q2=
- 上一篇:基于梯度法編寫的RBF神經網絡程序.
- 下一篇:Arduino 超聲波庫函數
評論
共有 條評論