加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
car.cpp 1.30 KB
一键复制 编辑 原始数据 按行查看 历史
小奇 提交于 2021-08-02 17:20 . 20210802
#include "car.h"
void goFront()
{
digitalWrite(leftMotor1, LOW);
digitalWrite(leftMotor2, HIGH);
digitalWrite(rightMotor1, LOW);
digitalWrite(rightMotor2, HIGH);
}
void goBack()
{
digitalWrite(leftMotor1, HIGH);
digitalWrite(leftMotor2, LOW);
digitalWrite(rightMotor1, HIGH);
digitalWrite(rightMotor2, LOW);
}
void goLeft()
{
digitalWrite(leftMotor1, HIGH);
digitalWrite(leftMotor2, LOW);
digitalWrite(rightMotor1, LOW);
digitalWrite(rightMotor2, HIGH);
}
void goRight()
{
digitalWrite(leftMotor1, LOW);
digitalWrite(leftMotor2, HIGH);
digitalWrite(rightMotor1, HIGH);
digitalWrite(rightMotor2, LOW);
}
void goStop()
{
digitalWrite(leftMotor1, LOW);
digitalWrite(leftMotor2, LOW);
digitalWrite(rightMotor1, LOW);
digitalWrite(rightMotor2, LOW);
}
void intcar()
{
pinMode(leftPWM, OUTPUT);
pinMode(rightPWM, OUTPUT);
pinMode(leftMotor1, OUTPUT);
pinMode(leftMotor2, OUTPUT);
pinMode(rightMotor1, OUTPUT);
pinMode(rightMotor2, OUTPUT);
analogFrequency(70000);
}
void set_speed_left(uint16_t value)
{
analogWrite(leftPWM, value);
}
void set_speed_right(uint16_t value)
{
analogWrite(rightPWM, value);
}
void set_speed_all(uint16_t value)
{
analogWrite(leftPWM, value);
analogWrite(rightPWM, value);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化