Okaaay so:
I had an mBot which worked perfectly, played with it a long time and really liked it. A few weeks ago, I bought some parts, including a Starter Robot Kit (IR version) and a Robotic Arm Add-on. I connected the arm motor to an Adafruit motor driver to MCore and it’s okay. In the dual motor driver, I put 2 grippers.
I first tried a little code using Ir remote on starter robot kit( without ultrasonic) and it worked just fine. Then I added everything, including the arm. It doesn’t work anymore. A part of the code was written in mBlock.
Here is the code.
Can someone make this okay (viteza = speed)???
There are no visible errors. Please. RGB led strips light up. Ports okay.
And PS in original code I used # before include. and the wire, softwareserial and Arduino libraries between <> not “”. Also tried without Arduino library, same result.
Is there a weight limit for DCMotors? They were pretty slow when it worked. The robot is around 2-3 kilos now. Still, it wouldn’t have sense for the gripper motors to not work. I tried Blink and it worked. I tried a program only with motor.run(255); in loop and didn’t work.
include "MeOrion.h"
include "SoftwareSerial.h"
include "Wire.h"
include “Arduino.h”
MeInfraredReceiver ir(PORT_6);
MeDCMotor motor_right(M1);
MeDCMotor motor_left(M2);
MeDCMotor motor_claw1(PORT_1);
MeDCMotor motor_claw2(PORT_2);
MeRGBLed rgbled_4_1(4, 1, 32);
MeRGBLed rgbled_4_2(4, 2, 32);
int viteza = 150;
void setup(){
ir.begin();
}
void loop(){
if(ir.available()){
rgbled_4_1.setColor(0,255,255,255);
rgbled_4_1.show();
rgbled_4_2.setColor(0,0,0,255);
rgbled_4_2.show();
switch(ir.read()){
case IR_BUTTON_D:
motor_claw1.run(50);
motor_claw2.run(50);
break;
case IR_BUTTON_E:
motor_claw2.run(-50);
motor_claw1.run(-50);
break;
case IR_BUTTON_UP:
motor_right.run(viteza);
motor_left.run(viteza);
break;
case IR_BUTTON_DOWN:
motor_right.run(-viteza);
motor_left.run(-viteza);
break;
case IR_BUTTON_LEFT:
motor_right.run(viteza);
motor_left.run(-viteza);
break;
case IR_BUTTON_RIGHT:
motor_left.run(viteza);
motor_right.run(-viteza);
break;
case IR_BUTTON_1: viteza = 50; break;
case IR_BUTTON_2: viteza = 75; break;
case IR_BUTTON_3: viteza = 100; break;
case IR_BUTTON_4: viteza = 125; break;
case IR_BUTTON_5: viteza = 150; break;
case IR_BUTTON_6: viteza = 175; break;
case IR_BUTTON_7: viteza = 200; break;
case IR_BUTTON_8: viteza = 225; break;
case IR_BUTTON_9: viteza = 255; break;
default:
motor_left.stop();
motor_right.stop();
motor_claw1.stop();
motor_claw2.stop();
break;
}
}
}