12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #include "FR_DCMotor.h"
-
-
- FR_DCMotor::FR_DCMotor(byte pinF,byte pinR)
- {
- _pinF=pinF;
- _pinR=pinR;
- init();
- }
-
- void FR_DCMotor::init()
- {
- pinMode(_pinF,OUTPUT);
- pinMode(_pinR,OUTPUT);
- }
-
- void FR_DCMotor::rotate(char dir, byte speed)
- {
- if(dir=='f' || dir=='F')
- {
- analogWrite(_pinR,0);
- for(int i=speed/4;i<=speed;i++)
- analogWrite(_pinF,i);
-
- }
- else if(dir=='r' || dir=='R')
- {
- analogWrite(_pinF,0);
- for(int i=speed/4;i<=speed;i++)
- analogWrite(_pinR,i);
- }
- else if(dir=='s' || dir=='S')
- {
- analogWrite(_pinF,0);
- analogWrite(_pinR,0);
- }
- }
-
- void FR_DCMotor::rotate(char dir)
- {
- if(dir=='s' || dir=='S')
- {
- analogWrite(_pinF,0);
- analogWrite(_pinR,0);
- }
- }
|