DFRobot DFR0225 Скачать руководство пользователя страница 8

//Standard DLL Speed control

int E1 = 4;     //M1 Speed Control
int E2 = 7;     //M2 Speed Control
int M1 = 5;    //M1 Direction Control
int M2 = 6;    //M1 Direction Control

///For previous Romeo, please use these pins.
//int E1 = 6;     //M1 Speed Control
//int E2 = 9;     //M2 Speed Control
//int M1 = 7;    //M1 Direction Control
//int M2 = 8;    //M1 Direction Control

//When m1p/m2p is 127, it stops the motor
//when m1p/m2p is 255, it gives the maximum speed for one direction
//When m1p/m2p is 0, it gives the maximum speed for reverse direction

void DriveMotorP(byte m1p, byte m2p)//Drive Motor Power Mode
{

  digitalWrite(E1, HIGH);
  analogWrite(M1, (m1p)); 

  digitalWrite(E2, HIGH);
  analogWrite(M2, (m2p)); 

}

void setup(void) 

  int i;
  for(i=6;i<=9;i++)
    pinMode(i, OUTPUT);  
  Serial.begin(19200);      //Set Baud Rate

void loop(void) 

  if(Serial.available()){
    char val = Serial.read();
    if(val!=‐1)
    {
      switch(val)
      {
      case 'w'://Move Forward
        DriveMotorP(0xff,0xff); // Max speed
        break;
      case 'x'://Move Backward
        DriveMotorP(0x00,0x00);
        ; // Max speed
        break;
      case 's'://Stop
        DriveMotorP(0x7f,0x7f);
        break;       

      }
    }
  }
}

Trouble shooting

More question and cool idea, visit DFRobot Forum (http://www.dfrobot.com/index.php?route=DFblog/blogs)

More

Romeo Schematic V2 (http://www.dfrobot.com/image/data/DFR0225/Romeo%20V2.0%20sch.pdf)

 (http://www.dfrobot.com/) BUY from DFRobot Store (http://www.dfrobot.com/index.php?

route=product/product&filter_name=romeo&product_id=844) or DFRobot Distributor List
(http://www.dfrobot.com/index.php?route=information/distributorslogo) 

Содержание DFR0225

Страница 1: ...ed by thousands of open source codes and can easily be expanded with Arduino Shields The integrated 2 way DC motor driver and Xbee socket allows you to start your project immediatly without the need f...

Страница 2: ...sensing switching external power input Support Male and Female Pin Header Built in Xbee socket Integrated sockets for APC220 RF Module and DF Bluetooth Module Three I2C TWI Interface Pin Sets two 90...

Страница 3: ...ng 6 12v servos with the voltage input higher than 5v it s not available to extend 5v sensor on all the digital sensor interface anymore The servo power terminal won t supply system working voltage Mo...

Страница 4: ...y if keypress is detected delay 50 wait for debounce time adc_key_in analogRead 0 read the value from the sensor key get_key adc_key_in convert into key press if key oldkey oldkey key if key 0 Serial...

Страница 5: ...ng Fig4 PWM Motor Control Pin Allocation The PWM DC motor control is implemented by manipulating two digital IO pins and two PWM pins As illustrated in the diagram above Figure 5 Pin 4 7 7 8 for old R...

Страница 6: ...1 a digitalWrite M1 LOW analogWrite E2 b digitalWrite M2 LOW void turn_L char a char b Turn Left analogWrite E1 a digitalWrite M1 LOW analogWrite E2 b digitalWrite M2 HIGH void turn_R char a char b Tu...

Страница 7: ...top PLL Control Mode The Romeo also supports PLLPhase locked loop wiki index php Phase_locked_loop control mode wiki index php File Romeov11xxx png Fig5 PLL Motor Control Pin Allocation Configuration...

Страница 8: ...e E2 HIGH analogWrite M2 m2p void setup void int i for i 6 i 9 i pinMode i OUTPUT Serial begin 19200 Set Baud Rate void loop void if Serial available char val Serial read if val 1 switch val case w Mo...

Страница 9: ...Controllers wiki index php Category Motor_Controllers MicroControllers wiki index php Category MicroControllers This page was last modified on 14 March 2016 at 04 15 Content is available under GNU Fr...

Отзывы: