├── 20kg Mecanum wheel Installation Manual.pdf ├── 80mm Mecanum Wheel Car Installation Manual.pdf ├── Assembly Steps ├── 01 - Attach Wheel Mounts.jpeg ├── 02 - Plan Motors so Connectors are Oriented Inwards.jpeg ├── 03 - Screw in Motors.jpeg ├── 04 - Prepare Wheel Assembly.jpeg ├── 05 - Screw in Axle.jpeg ├── 06 - Prepare Set Screw.jpeg ├── 07 - Wheels Ready.jpeg ├── 08 - Align Wheel Set Screw to Axel Flat Area.jpeg ├── 09 - Firmly Apply Set Screw.jpeg ├── 10 - Prepare Arduino Mega2560.jpeg ├── 11 - Plan Mounting Points.jpeg ├── 12 - Mount Mega2560.jpeg ├── 12 - Prepare IO Shield.jpeg ├── 13 - Align IO Shield to Mega2560.jpeg ├── 14 - Use Foam to Press Firmly.jpeg ├── 15 - Check Seating of Boards.jpeg ├── 16 - Prepare Motor Cables.jpeg ├── 17 - Plug in Front Motors.jpeg ├── 18 - Front Motors Underside.jpeg ├── 19 - Plug in Rear Motors (via center hole).jpeg ├── 20 - Rear Wheels via Center Hole.jpeg ├── 21 - Plug in PS2 Receiver.jpeg ├── 22 - PS2 Receiver Alignment.jpeg └── Pay attention to the direction of installing the wheels.jpg ├── BT2560.ino ├── CH340.zip ├── Code for line patrol and obstacle avoidance.zip ├── Encoder interface.png ├── Handle remote control & Bluetooth remote control operation instructions.pdf ├── MecanumRobotPS2Control.ino ├── MecanumRobotPS2control.png ├── Mega2560-Model airplane handle.zip ├── Motor interface.png ├── PS2X_lib.zip ├── PS2_2560 └── PS2_2560.ino ├── README.md ├── Visual_Nav_Impl-master.zip ├── bord.jpg ├── mega2560__2024-7(update).pdf ├── mega2560_sch.pdf └── mega2560pin.xls /20kg Mecanum wheel Installation Manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/20kg Mecanum wheel Installation Manual.pdf -------------------------------------------------------------------------------- /80mm Mecanum Wheel Car Installation Manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/80mm Mecanum Wheel Car Installation Manual.pdf -------------------------------------------------------------------------------- /Assembly Steps/01 - Attach Wheel Mounts.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/01 - Attach Wheel Mounts.jpeg -------------------------------------------------------------------------------- /Assembly Steps/02 - Plan Motors so Connectors are Oriented Inwards.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/02 - Plan Motors so Connectors are Oriented Inwards.jpeg -------------------------------------------------------------------------------- /Assembly Steps/03 - Screw in Motors.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/03 - Screw in Motors.jpeg -------------------------------------------------------------------------------- /Assembly Steps/04 - Prepare Wheel Assembly.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/04 - Prepare Wheel Assembly.jpeg -------------------------------------------------------------------------------- /Assembly Steps/05 - Screw in Axle.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/05 - Screw in Axle.jpeg -------------------------------------------------------------------------------- /Assembly Steps/06 - Prepare Set Screw.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/06 - Prepare Set Screw.jpeg -------------------------------------------------------------------------------- /Assembly Steps/07 - Wheels Ready.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/07 - Wheels Ready.jpeg -------------------------------------------------------------------------------- /Assembly Steps/08 - Align Wheel Set Screw to Axel Flat Area.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/08 - Align Wheel Set Screw to Axel Flat Area.jpeg -------------------------------------------------------------------------------- /Assembly Steps/09 - Firmly Apply Set Screw.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/09 - Firmly Apply Set Screw.jpeg -------------------------------------------------------------------------------- /Assembly Steps/10 - Prepare Arduino Mega2560.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/10 - Prepare Arduino Mega2560.jpeg -------------------------------------------------------------------------------- /Assembly Steps/11 - Plan Mounting Points.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/11 - Plan Mounting Points.jpeg -------------------------------------------------------------------------------- /Assembly Steps/12 - Mount Mega2560.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/12 - Mount Mega2560.jpeg -------------------------------------------------------------------------------- /Assembly Steps/12 - Prepare IO Shield.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/12 - Prepare IO Shield.jpeg -------------------------------------------------------------------------------- /Assembly Steps/13 - Align IO Shield to Mega2560.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/13 - Align IO Shield to Mega2560.jpeg -------------------------------------------------------------------------------- /Assembly Steps/14 - Use Foam to Press Firmly.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/14 - Use Foam to Press Firmly.jpeg -------------------------------------------------------------------------------- /Assembly Steps/15 - Check Seating of Boards.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/15 - Check Seating of Boards.jpeg -------------------------------------------------------------------------------- /Assembly Steps/16 - Prepare Motor Cables.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/16 - Prepare Motor Cables.jpeg -------------------------------------------------------------------------------- /Assembly Steps/17 - Plug in Front Motors.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/17 - Plug in Front Motors.jpeg -------------------------------------------------------------------------------- /Assembly Steps/18 - Front Motors Underside.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/18 - Front Motors Underside.jpeg -------------------------------------------------------------------------------- /Assembly Steps/19 - Plug in Rear Motors (via center hole).jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/19 - Plug in Rear Motors (via center hole).jpeg -------------------------------------------------------------------------------- /Assembly Steps/20 - Rear Wheels via Center Hole.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/20 - Rear Wheels via Center Hole.jpeg -------------------------------------------------------------------------------- /Assembly Steps/21 - Plug in PS2 Receiver.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/21 - Plug in PS2 Receiver.jpeg -------------------------------------------------------------------------------- /Assembly Steps/22 - PS2 Receiver Alignment.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/22 - PS2 Receiver Alignment.jpeg -------------------------------------------------------------------------------- /Assembly Steps/Pay attention to the direction of installing the wheels.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Assembly Steps/Pay attention to the direction of installing the wheels.jpg -------------------------------------------------------------------------------- /BT2560.ino: -------------------------------------------------------------------------------- 1 | //电机引脚 2 | #define PWMA 12 //A电机转速 3 | #define DIRA1 34 4 | #define DIRA2 35 //A电机方向 5 | #define PWMB 8 //B电机转速 6 | #define DIRB1 37 7 | #define DIRB2 36 //B电机方向 8 | #define PWMC 9 //C电机转速 9 | #define DIRC1 43 10 | #define DIRC2 42 //C电机方向 11 | #define PWMD 5 //D电机转速 12 | #define DIRD1 A4 //26 13 | #define DIRD2 A5 //27 //D电机方向 14 | 15 | #define MOTORA_FORWARD(pwm) do{digitalWrite(DIRA1,LOW); digitalWrite(DIRA2,HIGH);analogWrite(PWMA,pwm);}while(0) 16 | #define MOTORA_STOP(x) do{digitalWrite(DIRA1,LOW); digitalWrite(DIRA2,LOW); analogWrite(PWMA,0);}while(0) 17 | #define MOTORA_BACKOFF(pwm) do{digitalWrite(DIRA1,HIGH);digitalWrite(DIRA2,LOW); analogWrite(PWMA,pwm);}while(0) 18 | 19 | #define MOTORB_FORWARD(pwm) do{digitalWrite(DIRB1,LOW); digitalWrite(DIRB2,HIGH);analogWrite(PWMB,pwm);}while(0) 20 | #define MOTORB_STOP(x) do{digitalWrite(DIRB1,LOW); digitalWrite(DIRB2,LOW); analogWrite(PWMB,0);}while(0) 21 | #define MOTORB_BACKOFF(pwm) do{digitalWrite(DIRB1,HIGH);digitalWrite(DIRB2,LOW); analogWrite(PWMB,pwm);}while(0) 22 | 23 | #define MOTORC_FORWARD(pwm) do{digitalWrite(DIRC1,LOW); digitalWrite(DIRC2,HIGH);analogWrite(PWMC,pwm);}while(0) 24 | #define MOTORC_STOP(x) do{digitalWrite(DIRC1,LOW); digitalWrite(DIRC2,LOW); analogWrite(PWMC,0);}while(0) 25 | #define MOTORC_BACKOFF(pwm) do{digitalWrite(DIRC1,HIGH);digitalWrite(DIRC2,LOW); analogWrite(PWMC,pwm);}while(0) 26 | 27 | #define MOTORD_FORWARD(pwm) do{digitalWrite(DIRD1,LOW); digitalWrite(DIRD2,HIGH);analogWrite(PWMD,pwm);}while(0) 28 | #define MOTORD_STOP(x) do{digitalWrite(DIRD1,LOW); digitalWrite(DIRD2,LOW); analogWrite(PWMD,0);}while(0) 29 | #define MOTORD_BACKOFF(pwm) do{digitalWrite(DIRD1,HIGH);digitalWrite(DIRD2,LOW); analogWrite(PWMD,pwm);}while(0) 30 | 31 | #define SERIAL Serial 32 | 33 | #define LOG_DEBUG 34 | 35 | #ifdef LOG_DEBUG 36 | #define M_LOG SERIAL.print 37 | #else 38 | #define M_LOG 39 | #endif 40 | 41 | #define MAX_PWM 200 42 | #define MIN_PWM 130 43 | int Motor_PWM = 130; 44 | 45 | //控制电机运动 宏定义 46 | 47 | 48 | // ↑A-----B↑ 49 | // | ↑ | 50 | // | | | 51 | // ↑C-----D↑ 52 | void ADVANCE() 53 | { 54 | MOTORA_FORWARD(Motor_PWM);MOTORB_FORWARD(Motor_PWM); 55 | MOTORC_FORWARD(Motor_PWM);MOTORD_FORWARD(Motor_PWM); 56 | } 57 | 58 | // ↓A-----B↓ 59 | // | | | 60 | // | ↓ | 61 | // ↓C-----D↓ 62 | void BACK() 63 | { 64 | MOTORA_BACKOFF(Motor_PWM);MOTORB_BACKOFF(Motor_PWM); 65 | MOTORC_BACKOFF(Motor_PWM);MOTORD_BACKOFF(Motor_PWM); 66 | } 67 | // =A-----B↑ 68 | // | ↖ | 69 | // | ↖ | 70 | // ↑C-----D= 71 | void LEFT_1() 72 | { 73 | MOTORA_FORWARD(Motor_PWM);MOTORB_STOP(Motor_PWM); 74 | MOTORC_STOP(Motor_PWM);MOTORD_FORWARD(Motor_PWM); 75 | } 76 | 77 | // ↓A-----B↑ 78 | // | ← | 79 | // | ← | 80 | // ↑C-----D↓ 81 | void LEFT_2() 82 | { 83 | MOTORA_BACKOFF(Motor_PWM);MOTORB_FORWARD(Motor_PWM); 84 | MOTORC_FORWARD(Motor_PWM);MOTORD_BACKOFF(Motor_PWM); 85 | } 86 | // ↓A-----B= 87 | // | ↙ | 88 | // | ↙ | 89 | // =C-----D↓ 90 | void LEFT_3() 91 | { 92 | MOTORA_BACKOFF(Motor_PWM);MOTORB_STOP(Motor_PWM); 93 | MOTORC_STOP(Motor_PWM);MOTORD_BACKOFF(Motor_PWM); 94 | } 95 | // ↑A-----B= 96 | // | ↗ | 97 | // | ↗ | 98 | // =C-----D↑ 99 | void RIGHT_1() 100 | { 101 | MOTORA_FORWARD(Motor_PWM);MOTORB_STOP(Motor_PWM); 102 | MOTORC_STOP(Motor_PWM);MOTORD_FORWARD(Motor_PWM); 103 | } 104 | // ↑A-----B↓ 105 | // | → | 106 | // | → | 107 | // ↓C-----D↑ 108 | void RIGHT_2() 109 | { 110 | MOTORA_FORWARD(Motor_PWM);MOTORB_BACKOFF(Motor_PWM); 111 | MOTORC_BACKOFF(Motor_PWM);MOTORD_FORWARD(Motor_PWM); 112 | } 113 | // =A-----B↓ 114 | // | ↘ | 115 | // | ↘ | 116 | // ↓C-----D= 117 | void RIGHT_3() 118 | { 119 | MOTORA_STOP(Motor_PWM);MOTORB_BACKOFF(Motor_PWM); 120 | MOTORC_BACKOFF(Motor_PWM);MOTORD_STOP(Motor_PWM); 121 | } 122 | // =A-----B= 123 | // | = | 124 | // | = | 125 | // =C-----D= 126 | void STOP() 127 | { 128 | MOTORA_STOP(Motor_PWM);MOTORB_STOP(Motor_PWM); 129 | MOTORC_STOP(Motor_PWM);MOTORD_STOP(Motor_PWM); 130 | } 131 | void UART_Control() 132 | { 133 | char Uart_Date=0; 134 | if(SERIAL.available()) 135 | { 136 | Uart_Date = SERIAL.read(); 137 | } 138 | switch(Uart_Date) 139 | { 140 | case 'A': ADVANCE(); M_LOG("Run!\r\n"); break; 141 | case 'B': RIGHT_1(); M_LOG("Right up!\r\n"); break; 142 | case 'C': RIGHT_2(); M_LOG("Right!\r\n"); break; 143 | case 'D': RIGHT_3(); M_LOG("Right down!\r\n"); break; 144 | case 'E': BACK(); M_LOG("Run!\r\n"); break; 145 | case 'F': LEFT_3(); M_LOG("Left down!\r\n"); break; 146 | case 'G': LEFT_2(); M_LOG("Left!\r\n"); break; 147 | case 'H': LEFT_1(); M_LOG("Left up!\r\n"); break; 148 | case 'Z': STOP(); M_LOG("Stop!\r\n"); break; 149 | case 'L': Motor_PWM = 240; break; 150 | case 'M': Motor_PWM = 130; break; 151 | } 152 | } 153 | void IO_init() 154 | { 155 | pinMode(PWMA, OUTPUT); 156 | pinMode(DIRA1, OUTPUT);pinMode(DIRA2, OUTPUT); 157 | pinMode(PWMB, OUTPUT); 158 | pinMode(DIRB1, OUTPUT);pinMode(DIRB2, OUTPUT); 159 | pinMode(PWMC, OUTPUT); 160 | pinMode(DIRC1, OUTPUT);pinMode(DIRC2, OUTPUT); 161 | pinMode(PWMD, OUTPUT); 162 | pinMode(DIRD1, OUTPUT);pinMode(DIRD2, OUTPUT); 163 | STOP(); 164 | } 165 | void setup() 166 | { 167 | SERIAL.begin(9600); 168 | IO_init(); 169 | 170 | // SERIAL.print("Start"); 171 | } 172 | 173 | void loop() 174 | { 175 | UART_Control();//串口接收处理 176 | //CAR_Control();//小车控制 177 | 178 | } 179 | -------------------------------------------------------------------------------- /CH340.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/CH340.zip -------------------------------------------------------------------------------- /Code for line patrol and obstacle avoidance.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Code for line patrol and obstacle avoidance.zip -------------------------------------------------------------------------------- /Encoder interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Encoder interface.png -------------------------------------------------------------------------------- /Handle remote control & Bluetooth remote control operation instructions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Handle remote control & Bluetooth remote control operation instructions.pdf -------------------------------------------------------------------------------- /MecanumRobotPS2Control.ino: -------------------------------------------------------------------------------- 1 | // NOTE: requires the Encoder library. 2 | // 1) open Tools -> Manage Libraries... 3 | // 2) install "Encoder" by Paul Stoffregen v1.4.1 4 | #include 5 | 6 | // NOTE: Requires the PS2X_lib installed. 7 | // 1) open Sketch -> Include Library -> Add .ZIP Library 8 | // 2) select "PS2X_lib.zip" 9 | #include 10 | 11 | //PS2 12 | #define PS2_DAT 52 //14 13 | #define PS2_CMD 51 //15 14 | #define PS2_SEL 53 //16 15 | #define PS2_CLK 50 //17 16 | 17 | // #define pressures true 18 | #define pressures false 19 | #define rumble true 20 | //#define rumble false 21 | PS2X ps2x; // create PS2 Controller Class 22 | 23 | int error = 0; 24 | byte type = 0; 25 | byte vibrate = 0; 26 | 27 | void (* resetFunc) (void) = 0; 28 | 29 | // --- SPD Motor --- 30 | 31 | class SPDMotor { 32 | public: 33 | SPDMotor( int encoderA, int encoderB, bool encoderReversed, int motorPWM, int motorDir1, int motorDir2 ); 34 | 35 | /// Set the PWM speed and direction pins. 36 | /// pwm = 0, stop (no active control) 37 | /// pwm = 1 to 255, proportion of CCW rotation 38 | /// pwm = -1 to -255, proportion of CW rotation 39 | void speed( int pwm ); 40 | 41 | /// Activate a SHORT BRAKE mode, which shorts the motor drive EM, clamping motion. 42 | void hardStop(); 43 | 44 | /// Get the current speed. 45 | int getSpeed(); 46 | 47 | /// Get the current rotation position from the encoder. 48 | long getEncoderPosition(); 49 | 50 | private: 51 | Encoder *_encoder; 52 | bool _encoderReversed; 53 | int _motorPWM, _motorDir1, _motorDir2; 54 | 55 | // Current speed setting. 56 | int _speed; 57 | }; 58 | 59 | SPDMotor::SPDMotor( int encoderA, int encoderB, bool encoderReversed, int motorPWM, int motorDir1, int motorDir2 ) { 60 | _encoder = new Encoder(encoderA, encoderB); 61 | _encoderReversed = encoderReversed; 62 | 63 | _motorPWM = motorPWM; 64 | pinMode( _motorPWM, OUTPUT ); 65 | _motorDir1 = motorDir1; 66 | pinMode( _motorDir1, OUTPUT ); 67 | _motorDir2 = motorDir2; 68 | pinMode( _motorDir2, OUTPUT ); 69 | } 70 | 71 | /// Set the PWM speed and direction pins. 72 | /// pwm = 0, stop (no active control) 73 | /// pwm = 1 to 255, proportion of CCW rotation 74 | /// pwm = -1 to -255, proportion of CW rotation 75 | void SPDMotor::speed( int speedPWM ) { 76 | _speed = speedPWM; 77 | if( speedPWM == 0 ) { 78 | digitalWrite(_motorDir1,LOW); 79 | digitalWrite(_motorDir2,LOW); 80 | analogWrite( _motorPWM, 255); 81 | } else if( speedPWM > 0 ) { 82 | digitalWrite(_motorDir1, LOW ); 83 | digitalWrite(_motorDir2, HIGH ); 84 | analogWrite( _motorPWM, speedPWM < 255 ? speedPWM : 255); 85 | } else if( speedPWM < 0 ) { 86 | digitalWrite(_motorDir1, HIGH ); 87 | digitalWrite(_motorDir2, LOW ); 88 | analogWrite( _motorPWM, (-speedPWM) < 255 ? (-speedPWM): 255); 89 | } 90 | } 91 | 92 | /// Activate a SHORT BRAKE mode, which shorts the motor drive EM, clamping motion. 93 | void SPDMotor::hardStop() { 94 | _speed = 0; 95 | digitalWrite(_motorDir1,HIGH); 96 | digitalWrite(_motorDir2,HIGH); 97 | analogWrite( _motorPWM, 0); 98 | } 99 | 100 | /// Get the current speed. 101 | int SPDMotor::getSpeed() { 102 | return _speed; 103 | } 104 | 105 | /// Get the current rotation position from the encoder. 106 | long SPDMotor::getEncoderPosition() { 107 | long position = _encoder->read(); 108 | return _encoderReversed ? -position : position; 109 | } 110 | 111 | SPDMotor *motorLF = new SPDMotor(18, 31, true, 12, 34, 35); // <- Encoder reversed to make +position measurement be forward. 112 | SPDMotor *motorRF = new SPDMotor(19, 38, false, 8, 36, 37); // <- NOTE: Motor Dir pins reversed for opposite operation 113 | SPDMotor *motorLR = new SPDMotor( 3, 49, true, 9, 43, 42); // <- Encoder reversed to make +position measurement be forward. 114 | SPDMotor *motorRR = new SPDMotor( 2, A1, false, 5, A4, A5); // <- NOTE: Motor Dir pins reversed for opposite operation 115 | 116 | void setup() 117 | { 118 | Serial.begin(9600); 119 | delay(300) ;//added delay to give wireless ps2 module some time to startup, before configuring it 120 | //CHANGES for v1.6 HERE!!! **************PAY ATTENTION************* 121 | 122 | //setup pins and settings: GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error 123 | error = ps2x.config_gamepad(PS2_CLK, PS2_CMD, PS2_SEL, PS2_DAT, pressures, rumble); 124 | 125 | if (error == 0) { 126 | Serial.println("Found Controller, configuration successful "); 127 | Serial.println(); 128 | Serial.println("SPDMotor control by Aaron Hilton of Steampunk Digital"); 129 | Serial.println("====================================================="); 130 | Serial.println("Holding L1 or R1 will activate analog joystick control."); 131 | Serial.println("Left analog stick for forward/back and turning."); 132 | Serial.println("Right analog stick for sideways movement."); 133 | Serial.println("Hold both L1 and R1 for full-speed."); 134 | } 135 | else if (error == 1) 136 | { 137 | Serial.println("No controller found, check PS2 receiver is inserted the correct way around."); 138 | resetFunc(); 139 | } 140 | else if (error == 2) 141 | Serial.println("Controller found but not accepting commands."); 142 | 143 | else if (error == 3) 144 | Serial.println("Controller refusing to enter Pressures mode, may not support it. "); 145 | 146 | type = ps2x.readType(); 147 | switch (type) { 148 | case 0: 149 | Serial.println("Unknown Controller type found "); 150 | break; 151 | case 1: 152 | Serial.println("DualShock Controller found "); 153 | break; 154 | case 2: 155 | Serial.println("GuitarHero Controller found "); 156 | break; 157 | case 3: 158 | Serial.println("Wireless Sony DualShock Controller found "); 159 | break; 160 | } 161 | } 162 | 163 | 164 | void loop() { 165 | if (error == 1) //skip loop if no controller found 166 | return; 167 | 168 | if (type == 2) { //Guitar Hero Controller 169 | return; 170 | } 171 | else { //DualShock Controller 172 | static long oldSumPosition = 0; 173 | long sumPosition = motorLF->getEncoderPosition() + motorRF->getEncoderPosition() + motorLR->getEncoderPosition() + motorRR->getEncoderPosition(); 174 | long deltaPosition = sumPosition - oldSumPosition; 175 | oldSumPosition = sumPosition; 176 | Serial.print("∆pos: "); 177 | Serial.print(deltaPosition); 178 | long posVibrate = abs(deltaPosition); 179 | posVibrate = posVibrate > 255 ? 255 : 0; 180 | vibrate = (byte)posVibrate; 181 | ps2x.read_gamepad(false, vibrate); //read controller and set large motor to spin at 'vibrate' speed 182 | 183 | if (ps2x.Button(PSB_L1) || ps2x.Button(PSB_R1)) { 184 | int LY = ps2x.Analog(PSS_LY); 185 | int LX = ps2x.Analog(PSS_LX); 186 | int RX = ps2x.Analog(PSS_RX); 187 | float forwardNormalized = (float)(-LY + 128)/127.f; 188 | 189 | forwardNormalized = constrain( forwardNormalized, -1.f, 1.f ); 190 | float multiplier = (ps2x.Button(PSB_L1) && ps2x.Button(PSB_R1)) ? 255.f : 80.f; 191 | int forward = (int)(pow(forwardNormalized, 2.0) * multiplier); 192 | 193 | // Preserve the direction of movement. 194 | if( forwardNormalized < 0 ) { 195 | forward = -forward; 196 | } 197 | 198 | int right = -RX + 127; 199 | int ccwTurn = (LX - 127)/2; 200 | Serial.print( " fwd:" ); 201 | Serial.print( forward ); 202 | Serial.print( " r:" ); 203 | Serial.print( right ); 204 | Serial.print( " ∆°:" ); 205 | Serial.print( ccwTurn ); 206 | Serial.print( " LF:" ); 207 | Serial.print( motorLF->getEncoderPosition() ); 208 | Serial.print( " RF:" ); 209 | Serial.print( motorRF->getEncoderPosition() ); 210 | Serial.print( " LR:" ); 211 | Serial.print( motorLR->getEncoderPosition() ); 212 | Serial.print( " RR:" ); 213 | Serial.println( motorRR->getEncoderPosition() ); 214 | 215 | motorLF->speed(forward + ccwTurn - right); motorRF->speed(forward - ccwTurn + right); 216 | motorLR->speed(forward - ccwTurn - right); motorRR->speed(forward + ccwTurn + right); 217 | } else { 218 | // If there's motor power, try to hard-stop briefly. 219 | if( motorLF->getSpeed() != 0 220 | || motorRF->getSpeed() != 0 221 | || motorLR->getSpeed() != 0 222 | || motorRR->getSpeed() != 0 ) 223 | { 224 | motorLF->hardStop(); motorRF->hardStop(); 225 | motorLR->hardStop(); motorRR->hardStop(); 226 | delay(500); 227 | motorLF->speed(0); motorRF->speed(0); 228 | motorLR->speed(0); motorRR->speed(0); 229 | } 230 | } 231 | } 232 | } 233 | -------------------------------------------------------------------------------- /MecanumRobotPS2control.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/MecanumRobotPS2control.png -------------------------------------------------------------------------------- /Mega2560-Model airplane handle.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Mega2560-Model airplane handle.zip -------------------------------------------------------------------------------- /Motor interface.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Motor interface.png -------------------------------------------------------------------------------- /PS2X_lib.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/PS2X_lib.zip -------------------------------------------------------------------------------- /PS2_2560/PS2_2560.ino: -------------------------------------------------------------------------------- 1 | #include 2 | //电机引脚 3 | #define PWMA 12 //A电机转速 4 | #define DIRA1 34 5 | #define DIRA2 35 //A电机方向 6 | #define PWMB 8 //B电机转速 7 | #define DIRB1 37 8 | #define DIRB2 36 //B电机方向 9 | #define PWMC 9 //C电机转速 10 | #define DIRC1 43 11 | #define DIRC2 42 //C电机方向 12 | #define PWMD 5 //D电机转速 13 | #define DIRD1 A4 //26 14 | #define DIRD2 A5 //27 //D电机方向 15 | 16 | //PS2 17 | #define PS2_DAT 52 //14 18 | #define PS2_CMD 51 //15 19 | #define PS2_SEL 53 //16 20 | #define PS2_CLK 50 //17 21 | 22 | char speed; 23 | // #define pressures true 24 | #define pressures false 25 | // #define rumble true 26 | #define rumble false 27 | PS2X ps2x; // create PS2 Controller Class 28 | 29 | int error = 0; 30 | byte type = 0; 31 | byte vibrate = 0; 32 | 33 | void (* resetFunc) (void) = 0; 34 | 35 | #define MOTORA_FORWARD(pwm) do{digitalWrite(DIRA1,LOW); digitalWrite(DIRA2,HIGH);analogWrite(PWMA,pwm);}while(0) 36 | #define MOTORA_STOP(x) do{digitalWrite(DIRA1,LOW); digitalWrite(DIRA2,LOW); analogWrite(PWMA,0);}while(0) 37 | #define MOTORA_BACKOFF(pwm) do{digitalWrite(DIRA1,HIGH);digitalWrite(DIRA2,LOW); analogWrite(PWMA,pwm);}while(0) 38 | 39 | #define MOTORB_FORWARD(pwm) do{digitalWrite(DIRB1,HIGH); digitalWrite(DIRB2,LOW);analogWrite(PWMB,pwm);}while(0) 40 | #define MOTORB_STOP(x) do{digitalWrite(DIRB1,LOW); digitalWrite(DIRB2,LOW); analogWrite(PWMB,0);}while(0) 41 | #define MOTORB_BACKOFF(pwm) do{digitalWrite(DIRB1,LOW);digitalWrite(DIRB2,HIGH); analogWrite(PWMB,pwm);}while(0) 42 | 43 | #define MOTORC_FORWARD(pwm) do{digitalWrite(DIRC1,LOW); digitalWrite(DIRC2,HIGH);analogWrite(PWMC,pwm);}while(0) 44 | #define MOTORC_STOP(x) do{digitalWrite(DIRC1,LOW); digitalWrite(DIRC2,LOW); analogWrite(PWMC,0);}while(0) 45 | #define MOTORC_BACKOFF(pwm) do{digitalWrite(DIRC1,HIGH);digitalWrite(DIRC2,LOW); analogWrite(PWMC,pwm);}while(0) 46 | 47 | #define MOTORD_FORWARD(pwm) do{digitalWrite(DIRD1,HIGH); digitalWrite(DIRD2,LOW);analogWrite(PWMD,pwm);}while(0) 48 | #define MOTORD_STOP(x) do{digitalWrite(DIRD1,LOW); digitalWrite(DIRD2,LOW); analogWrite(PWMD,0);}while(0) 49 | #define MOTORD_BACKOFF(pwm) do{digitalWrite(DIRD1,LOW);digitalWrite(DIRD2,HIGH); analogWrite(PWMD,pwm);}while(0) 50 | 51 | #define SERIAL Serial 52 | 53 | #define LOG_DEBUG 54 | 55 | #ifdef LOG_DEBUG 56 | #define M_LOG SERIAL.print 57 | #else 58 | #define M_LOG 59 | #endif 60 | 61 | #define MAX_PWM 200 62 | #define MIN_PWM 130 63 | int Motor_PWM = 130; 64 | 65 | //控制电机运动 宏定义 66 | 67 | 68 | // ↑A-----B↑ 69 | // | ↑ | 70 | // | | | 71 | // ↑C-----D↑ 72 | void ADVANCE() 73 | { 74 | MOTORA_FORWARD(Motor_PWM);MOTORB_FORWARD(Motor_PWM); 75 | MOTORC_FORWARD(Motor_PWM);MOTORD_FORWARD(Motor_PWM); 76 | } 77 | 78 | // ↓A-----B↓ 79 | // | | | 80 | // | ↓ | 81 | // ↓C-----D↓ 82 | void BACK() 83 | { 84 | MOTORA_BACKOFF(Motor_PWM);MOTORB_BACKOFF(Motor_PWM); 85 | MOTORC_BACKOFF(Motor_PWM);MOTORD_BACKOFF(Motor_PWM); 86 | } 87 | // =A-----B↑ 88 | // | ↖ | 89 | // | ↖ | 90 | // ↑C-----D= 91 | void LEFT_1() 92 | { 93 | MOTORA_STOP(Motor_PWM);MOTORB_FORWARD(Motor_PWM); 94 | MOTORC_FORWARD(Motor_PWM);MOTORD_STOP(Motor_PWM); 95 | } 96 | 97 | // ↓A-----B↑ 98 | // | ← | 99 | // | ← | 100 | // ↑C-----D↓ 101 | void LEFT_2() 102 | { 103 | MOTORA_BACKOFF(Motor_PWM);MOTORB_FORWARD(Motor_PWM); 104 | MOTORC_FORWARD(Motor_PWM);MOTORD_BACKOFF(Motor_PWM); 105 | } 106 | // ↓A-----B= 107 | // | ↙ | 108 | // | ↙ | 109 | // =C-----D↓ 110 | void LEFT_3() 111 | { 112 | MOTORA_BACKOFF(Motor_PWM);MOTORB_STOP(Motor_PWM); 113 | MOTORC_STOP(Motor_PWM);MOTORD_BACKOFF(Motor_PWM); 114 | } 115 | // ↑A-----B= 116 | // | ↗ | 117 | // | ↗ | 118 | // =C-----D↑ 119 | void RIGHT_1() 120 | { 121 | MOTORA_FORWARD(Motor_PWM);MOTORB_STOP(Motor_PWM); 122 | MOTORC_STOP(Motor_PWM);MOTORD_FORWARD(Motor_PWM); 123 | } 124 | // ↑A-----B↓ 125 | // | → | 126 | // | → | 127 | // ↓C-----D↑ 128 | void RIGHT_2() 129 | { 130 | MOTORA_FORWARD(Motor_PWM);MOTORB_BACKOFF(Motor_PWM); 131 | MOTORC_BACKOFF(Motor_PWM);MOTORD_FORWARD(Motor_PWM); 132 | } 133 | // =A-----B↓ 134 | // | ↘ | 135 | // | ↘ | 136 | // ↓C-----D= 137 | void RIGHT_3() 138 | { 139 | MOTORA_STOP(Motor_PWM);MOTORB_BACKOFF(Motor_PWM); 140 | MOTORC_BACKOFF(Motor_PWM);MOTORD_STOP(Motor_PWM); 141 | } 142 | // ↓A-----B↑ 143 | // | | 144 | // | | 145 | // ↓C-----D↑ 146 | void TURN_LEFT() 147 | { 148 | MOTORA_BACKOFF(Motor_PWM);MOTORB_FORWARD(Motor_PWM); 149 | MOTORC_BACKOFF(Motor_PWM);MOTORD_FORWARD(Motor_PWM); 150 | } 151 | // ↑A-----B↓ 152 | // | | 153 | // | | 154 | // ↑C-----D↓ 155 | void TURN_RIGHT() 156 | { 157 | MOTORA_FORWARD(Motor_PWM);MOTORB_BACKOFF(Motor_PWM); 158 | MOTORC_FORWARD(Motor_PWM);MOTORD_BACKOFF(Motor_PWM); 159 | } 160 | // =A-----B= 161 | // | = | 162 | // | = | 163 | // =C-----D= 164 | void STOP() 165 | { 166 | MOTORA_STOP(Motor_PWM);MOTORB_STOP(Motor_PWM); 167 | MOTORC_STOP(Motor_PWM);MOTORD_STOP(Motor_PWM); 168 | } 169 | void UART_Control() 170 | { 171 | char Uart_Date=0; 172 | if(SERIAL.available()) 173 | { 174 | Uart_Date = SERIAL.read(); 175 | } 176 | switch(Uart_Date) 177 | { 178 | case 'A': ADVANCE(); M_LOG("Run!\r\n"); break; 179 | case 'B': RIGHT_1(); M_LOG("Right up!\r\n"); break; 180 | case 'C': RIGHT_2(); M_LOG("Right!\r\n"); break; 181 | case 'D': RIGHT_3(); M_LOG("Right down!\r\n"); break; 182 | case 'E': BACK(); M_LOG("Run!\r\n"); break; 183 | case 'F': LEFT_3(); M_LOG("Left down!\r\n"); break; 184 | case 'G': LEFT_2(); M_LOG("Left!\r\n"); break; 185 | case 'H': LEFT_1(); M_LOG("Left up!\r\n"); break; 186 | case 'Z': STOP(); M_LOG("Stop!\r\n"); break; 187 | case 'L': Motor_PWM = 240; break; 188 | case 'M': Motor_PWM = 130; break; 189 | } 190 | } 191 | void IO_init() 192 | { 193 | pinMode(PWMA, OUTPUT); 194 | pinMode(DIRA1, OUTPUT); 195 | pinMode(DIRA2, OUTPUT); 196 | pinMode(PWMB, OUTPUT); 197 | pinMode(DIRB1, OUTPUT); 198 | pinMode(DIRB2, OUTPUT); 199 | pinMode(PWMC, OUTPUT); 200 | pinMode(DIRC1, OUTPUT); 201 | pinMode(DIRC2, OUTPUT); 202 | pinMode(PWMD, OUTPUT); 203 | pinMode(DIRD1, OUTPUT); 204 | pinMode(DIRD2, OUTPUT); 205 | STOP(); 206 | } 207 | void setup() 208 | { 209 | Serial.begin(9600); 210 | delay(300) ;//added delay to give wireless ps2 module some time to startup, before configuring it 211 | //CHANGES for v1.6 HERE!!! **************PAY ATTENTION************* 212 | 213 | //setup pins and settings: GamePad(clock, command, attention, data, Pressures?, Rumble?) check for error 214 | error = ps2x.config_gamepad(PS2_CLK, PS2_CMD, PS2_SEL, PS2_DAT, pressures, rumble); 215 | 216 | if (error == 0) { 217 | Serial.print("Found Controller, configured successful "); 218 | Serial.print("pressures = "); 219 | if (pressures) 220 | Serial.println("true "); 221 | else 222 | Serial.println("false"); 223 | Serial.print("rumble = "); 224 | if (rumble) 225 | Serial.println("true)"); 226 | else 227 | Serial.println("false"); 228 | Serial.println("Try out all the buttons, X will vibrate the controller, faster as you press harder;"); 229 | Serial.println("holding L1 or R1 will print out the analog stick values."); 230 | Serial.println("Note: Go to www.billporter.info for updates and to report bugs."); 231 | } 232 | else if (error == 1) 233 | { 234 | Serial.println("No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips"); 235 | resetFunc(); 236 | 237 | } 238 | 239 | else if (error == 2) 240 | Serial.println("Controller found but not accepting commands. see readme.txt to enable debug. Visit www.billporter.info for troubleshooting tips"); 241 | 242 | else if (error == 3) 243 | Serial.println("Controller refusing to enter Pressures mode, may not support it. "); 244 | 245 | // Serial.print(ps2x.Analog(1), HEX); 246 | 247 | type = ps2x.readType(); 248 | switch (type) { 249 | case 0: 250 | Serial.print("Unknown Controller type found "); 251 | break; 252 | case 1: 253 | Serial.print("DualShock Controller found "); 254 | break; 255 | case 2: 256 | Serial.print("GuitarHero Controller found "); 257 | break; 258 | case 3: 259 | Serial.print("Wireless Sony DualShock Controller found "); 260 | break; 261 | } 262 | IO_init(); 263 | 264 | // SERIAL.print("Start"); 265 | } 266 | 267 | 268 | void loop() { 269 | /* You must Read Gamepad to get new values and set vibration values 270 | ps2x.read_gamepad(small motor on/off, larger motor strenght from 0-255) 271 | if you don't enable the rumble, use ps2x.read_gamepad(); with no values 272 | You should call this at least once a second 273 | */ 274 | 275 | UART_Control();//串口接收处理 276 | if (error == 1) //skip loop if no controller found 277 | return; 278 | 279 | if (type == 2) { //Guitar Hero Controller 280 | return; 281 | } 282 | else { //DualShock Controller 283 | ps2x.read_gamepad(false, vibrate); //read controller and set large motor to spin at 'vibrate' speed 284 | 285 | 286 | //start 开始运行,电机初PWM为120; 287 | if (ps2x.Button(PSB_START)) { 288 | Serial.println("Start is being held"); 289 | Motor_PWM = 90; 290 | ADVANCE(); 291 | 292 | 293 | } 294 | // 电机正转; 295 | if (ps2x.Button(PSB_PAD_UP)) { 296 | Serial.println("Up held this hard: "); 297 | Motor_PWM = 120; 298 | ADVANCE(); 299 | } 300 | 301 | // 电机反转; 302 | if (ps2x.Button(PSB_PAD_DOWN)) { 303 | Serial.println("Down held this hard: "); 304 | Motor_PWM = 120; 305 | BACK(); 306 | } 307 | 308 | //左转; 309 | if (ps2x.Button(PSB_PAD_LEFT)) { 310 | Serial.println("turn left "); 311 | Motor_PWM = 120;//200 312 | LEFT_1(); 313 | } 314 | 315 | //右转; 316 | if (ps2x.Button(PSB_PAD_RIGHT)) { 317 | Serial.println("turn right"); 318 | Motor_PWM = 120;//200 319 | RIGHT_1(); 320 | } 321 | // Stop 322 | if (ps2x.Button(PSB_SELECT)) { 323 | Serial.println("stop"); 324 | STOP(); 325 | } 326 | // 左平移 327 | if (ps2x.Button(PSB_PINK)) { 328 | Serial.println("motor_pmove_left"); 329 | LEFT_2(); 330 | } 331 | // 右平移 332 | if (ps2x.Button(PSB_RED)) { 333 | Serial.println("motor_pmove_right"); 334 | RIGHT_2(); 335 | } 336 | // Turn left 337 | if(ps2x.Button(PSB_GREEN)) { 338 | Serial.println("turn left"); 339 | TURN_LEFT(); 340 | } 341 | // Turn right 342 | if(ps2x.Button(PSB_BLUE)) { 343 | Serial.println("turn right"); 344 | TURN_RIGHT(); 345 | } 346 | delay(20); 347 | 348 | } 349 | if (ps2x.Button(PSB_L1) || ps2x.Button(PSB_R1)) { //print stick values if either is TRUE 350 | Serial.print("Stick Values:"); 351 | Serial.print(ps2x.Analog(PSS_LY), DEC); //Left stick, Y axis. Other options: LX, RY, RX 352 | Serial.print(","); 353 | Serial.print(ps2x.Analog(PSS_LX), DEC); 354 | Serial.print(","); 355 | Serial.print(ps2x.Analog(PSS_RY), DEC); 356 | Serial.print(","); 357 | Serial.println(ps2x.Analog(PSS_RX), DEC); 358 | 359 | int LY = ps2x.Analog(PSS_LY); 360 | int LX = ps2x.Analog(PSS_LX); 361 | int RY = ps2x.Analog(PSS_RY); 362 | int RX = ps2x.Analog(PSS_RX); 363 | 364 | if (LY < 127) //前进 365 | { 366 | 367 | Motor_PWM = 1.5 * (127 - LY); 368 | ADVANCE(); 369 | delay(20); 370 | } 371 | //后退 372 | if (LY > 127) 373 | { 374 | Motor_PWM = 1.5 * (LY - 128); 375 | BACK(); 376 | delay(20); 377 | } 378 | //左转 379 | if (LX < 128) 380 | { 381 | Motor_PWM = 1.5 * (127 - LX); 382 | LEFT_1(); 383 | delay(20); 384 | } 385 | //右转 386 | if (LX > 128) 387 | { 388 | Motor_PWM = 1.5 * (LX - 128); 389 | RIGHT_3(); 390 | delay(20); 391 | } 392 | //如果摇杆居中 393 | if (LY >= 128 && LY <= 128 && LX >= 128 && LX <= 128) 394 | { 395 | STOP(); 396 | delay(20); 397 | } 398 | 399 | } 400 | } 401 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## NOTE 4 | This controller is included MEGA2560 board+ 4 channel motor driver board+ PS2 wireless controller, which can drive 4pcs motor with encoder specially for Mecanum wheel robot. It can move forward, backward, left, right, turn, sidesway, etc. What's more, you can develop it secondly, the driver board reserve servos interface can control the robot arm, can control the self-driving robot after adding a gyroscope because it can drive encoder motor. 5 | note:The new version of the driver board corresponds to the schematic diagram, pin 26 27 needs to be modified to A4 A5 6 | 7 | 8 | ## CH340Driver installation 9 | ### 10 | 1.Download the Windows CH340 Driver. 11 | 12 | 2.Unzip the file. 13 | 14 | 3.Run the installer which you unzipped. 15 | 16 | 4.In the Arduino IDE when the CH340 is connected you will see a COM Port in the Tools > Serial Port menu, the COM number for your device may vary depending on your system. 17 | 18 | ### Change the mega2560 diver sch and motor encoder interface:exchange 5V GND position 19 | ![Encoder interface](https://github.com/MoebiusTech/MecanumRobot-ArduinoMega2560/blob/master/Motor%20interface.png 20 | "Encoder interface") 21 | ## 22 | If you have any problems, please contact us: Whatsapp:+86 13699824373; Email: moebius@mbeus.com 23 | -------------------------------------------------------------------------------- /Visual_Nav_Impl-master.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/Visual_Nav_Impl-master.zip -------------------------------------------------------------------------------- /bord.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/bord.jpg -------------------------------------------------------------------------------- /mega2560__2024-7(update).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/mega2560__2024-7(update).pdf -------------------------------------------------------------------------------- /mega2560_sch.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/mega2560_sch.pdf -------------------------------------------------------------------------------- /mega2560pin.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MoebiusTech/MecanumRobot-ArduinoMega2560/b6da30e3575b4c01a073dc018de3b3c97b8622d5/mega2560pin.xls --------------------------------------------------------------------------------