#include
#include "MotorCar.h" //include后面加空格
#include "String.h"
MotorCar::MotorCar(int _slpin,nit _dlpin,int _srpin,int _drpin)
{
_speedLeftPin = _slpin;
_speedRightPin = _slpin;
_dirLeftPin = _dlpin;
_dirRightPin = _dlpin;
pinMode(_speedLeftPin,OUTPUT);
pinMode(_speedRightPin,OUTPUT);
pinMode(_dirLeftPin,OUTPUT);
pinMode(_dirRightPin,OUTPUT);
}
void MotorCar::forward(int _speed)
{
digitalWrite(_dirRightPin,HIGH);
digitalWrite(_dirLeftPin,HIGH);
analogWrite(_speedRightPin,_speed);
analogWrite(_speedLeftPin,_speed);}
void MotorCar::back(int _speed)
{
digitalWrite(_dirRightPin,LOW);
digitalWrite(_dirLeftPin,LOW);
analogWrite(_speedRightPin,_speed);
analogWrite(_speedLeftPin,_speed);}
void MotorCar::turnLeft(int _speed)
{
digitalWrite(_dirRightPin,HIGH);
analogWrite(_speedRightPin,_speed);
analogWrite(_speedLeftPin,0);}
void MotorCar::turnRight(int _speed)
{
digitalWrite(_dirleftPin,HIGH);
analogWrite(_speedRightPin,0);
analogWrite(_speedLeftPin,_speed);}
void MotorCar::turnLeftOrigin(int _speed)
{
digitalWrite(_dirRightPin,HIGH);
digitalWrite(_dirLeftPin,LOW);
analogWrite(_speedRightPin,_speed);
analogWrite(_speedLeftPin,_speed);}
void MotorCar::turnRightOrigin(int _speed)
{
digitalWrite(_dirLeftPin,HIGH);
digitalWrite(_dirRightPin,LOW);
analogWrite(_speedRightPin,_speed);
analogWrite(_speedLeftPin,_speed);}
void MotorCar::stop()
{
analogWrite(_speedRightPin, 0);
analogWrite(_speedLeftPin,0);}
出错详情:
function 'void MotorCar::stop()':
D:\Development\arduino-1.0.3\libraries\MotorCar\MototrCar.cpp:115:
error: 'analogWrite' was not declared in this scope