i have been trying to control an owi robotic arm with a tv remote. I have hooked up four of the motors to a motor control board and plugged in the IR receiver. This is my code:
#include <IRremote.h>
#include <IRremoteInt.h>
#include <AFMotor.h>
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);
int RECV_PIN = A5;
IRrecv irrecv(RECV_PIN);
decode_results results;
#define button1 0x1DE807F
#define button2 0x1DE40BF
#define button3 0x1DEC03F
#define button4 0x1DE20DF
#define button5 0x1DEA05F
#define button6 0x1DE609F
#define button7 0x1DEE01F
#define button8 0x1DE10EF
#define button9 0x1DE906F
void setup() {
motor1.setSpeed(200);
motor1.run(RELEASE);
motor2.setSpeed(200);
motor2.run(RELEASE);
motor3.setSpeed(200);
motor3.run(RELEASE);
motor4.setSpeed(200);
motor4.run(RELEASE);
irrecv.enableIRIn();
}
void loop() {
if (irrecv.decode(&results)){
if (results.value == button1) { //wrist
motor2.run(FORWARD);
delay(100);
motor2.run(RELEASE);
}
else if (results.value == button2) { //wrist
motor2.run(BACKWARD);
delay(100);
motor2.run(RELEASE);
}
else if (results.value == button4) { //elbow
motor3.run(FORWARD);
delay(100);
motor3.run(RELEASE);
}
else if (results.value == button5) { //elbow
motor3.run(BACKWARD);
delay(100);
motor3.run(RELEASE);
}
else if (results.value == button7) { //shoulder
motor4.run(FORWARD);
delay(100);
motor4.run(RELEASE);
}
else if (results.value == button8) { //shoulder
motor4.run(BACKWARD);
delay(100);
motor4.run(RELEASE);
}
else if (results.value == button3) { //gripper
motor1.run(FORWARD);
delay(100);
motor1.run(RELEASE);
}
else if (results.value == button6) { //gripper
motor1.run(BACKWARD);
delay(100);
motor1.run(RELEASE);
}
irrecv.resume();
}
}
I am powering the arm with a 7.2v battery pack and the separately arduino with a 5V USB battery pack. The problem is that motors 3 and 4 work fine but motors 1 and 2 show no signs of life. I have checked the motor shield with another sketch and it works fine, I've also checked the remote codes and they are correct. I have also tried control with a sketch using switch case statements but that doesn't work at all this is the code:
#include <IRremote.h>
#include <IRremoteInt.h>
#include <AFMotor.h>
AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);
int RECV_PIN = A5;
IRrecv irrecv(RECV_PIN);
decode_results results;
#define button1 0x1DE807F
#define button2 0x1DE40BF
#define button3 0x1DEC03F
#define button4 0x1DE20DF
#define button5 0x1DEA05F
#define button6 0x1DE609F
#define button7 0x1DEE01F
#define button8 0x1DE10EF
#define button9 0x1DE906F
void setup() {
motor1.setSpeed(200);
motor1.run(RELEASE);
motor2.setSpeed(200);
motor2.run(RELEASE);
motor3.setSpeed(200);
motor3.run(RELEASE);
motor4.setSpeed(200);
motor4.run(RELEASE);
irrecv.enableIRIn();
}
void loop() {
if (irrecv.decode(&results)){
switch(results.value) {
case button3: //gripper
motor1.run(FORWARD);
delay(100);
break;
case button6: //gripper
motor1.run(BACKWARD);
delay(100);
break;
case button1: //wrist
motor2.run(FORWARD);
delay(100);
break;
case button2: //wrist
motor2.run(BACKWARD);
delay(100);
break;
case button4: //elbow
motor3.run(FORWARD);
delay(100);
break;
case button5: //elbow
motor3.run(BACKWARD);
delay(100);
break;
case button7: //shoulder
motor4.run(FORWARD);
delay(100);
break;
case button8: //shoulder
motor4.run(BACKWARD);
delay(100);
break;
default:
motor1.run(RELEASE);
motor2.run(RELEASE);
motor3.run(RELEASE);
motor4.run(RELEASE);
}
}
irrecv.resume();
}
I would greatly appreciate any help you could offer