資源簡介
樹莓派小車循跡程序,c語言編寫 看看
代碼片段和文件信息
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#define?Trig 28
#define?Echo 29
#define?LEFT 27
#define?RIGHT 26
#define?BUFSIZE?512
#define?MOTOR_GO_FORWARD???digitalWrite(1HIGH);digitalWrite(4LOW);digitalWrite(5HIGH);digitalWrite(6LOW)
#define?MOTOR_GO_BACK ???digitalWrite(4HIGH);digitalWrite(1LOW);digitalWrite(6HIGH);digitalWrite(5LOW)
#define?MOTOR_GO_RIGHT ???digitalWrite(1HIGH);digitalWrite(4LOW);digitalWrite(6HIGH);digitalWrite(5LOW)
#define?MOTOR_GO_LEFT ???digitalWrite(4HIGH);digitalWrite(1LOW);digitalWrite(5HIGH);digitalWrite(6LOW)
#define?MOTOR_GO_STOP ???digitalWrite(1?LOW);digitalWrite(4LOW);digitalWrite(5?LOW);digitalWrite(6LOW)
void?run()?????//?前進
{
????softPwmWrite(40);?//左輪前進
softPwmWrite(1150);?
softPwmWrite(60);?//右輪前進
softPwmWrite(5150);?
?
}
void?brake()?????????//剎車,停車
{
????softPwmWrite(10);?//左輪
softPwmWrite(40);?
softPwmWrite(50);?//stop
softPwmWrite(60);?
??
}
void?left()?????????//左轉()
{
????softPwmWrite(4150);?//左輪
softPwmWrite(10);?
softPwmWrite(60);?//右輪前進
softPwmWrite(5150);?
}
void?right()?????
- 上一篇:基于51單片機的人體感應燈設計
- 下一篇:簡單的Linux下Ftp客戶端C語言編寫
評論
共有 條評論