Hey guys, frequent forum flyer, first time poster. I'm very new to Arduino, but excited about everything it has potential to do, so your help is appreciated in getting my project going.
Here's my situation: I am trying to make a (what should be) simple robotic vehicle with 2 DC motors in the rear, swivel wheels up front, and an H-bridge, that are controlled by an IR remote/receiver which was included in the starter kit. I used the code, edited for my specifics, and wiring schematic that can be found here: "Controlling DC Motors using Arduino and IR Remote". My specific code is posted below.
#include <IRremote.h>
#define Next 0xFFC23D//insert code for next button
#define Prev 0xFF22DD //insert code for prev button
#define Up 0xFF906F //insert code for up button
#define Down 0xFFE01F //insert code for down button
#define Pause 0xFF02FD //insert code for play/pause button
int receiver_pin = 2; //IR receiver is connected to pin 2 of arduino
int Yellow_motor1 = 11;
int Yellow_motor2 = 12;
int Black_motor1 = 6;
int Black_motor2 = 5;
IRrecv receiver(receiver_pin); //arduino takes output from receiver
decode_results output;
void setup() {
Serial.begin(9600);
receiver.enableIRIn(); //start to take output from IR receiver
//initializing all pins have connected led's as outputs
pinMode(Yellow_motor1, OUTPUT);
pinMode(Yellow_motor2, OUTPUT);
pinMode(Black_motor1, OUTPUT);
pinMode(Black_motor2, OUTPUT);
}
void loop() {
if (receiver.decode(&output)) {
unsigned int value = output.value;
Serial.println(output.value, HEX);
switch(value) {
case Next:
digitalWrite(Yellow_motor1, LOW);
digitalWrite(Yellow_motor2, HIGH);
digitalWrite(Black_motor1, HIGH);
digitalWrite(Black_motor2, LOW);
break;
case Prev:
digitalWrite(Yellow_motor1, HIGH);
digitalWrite(Yellow_motor2, LOW);
digitalWrite(Black_motor1, LOW);
digitalWrite(Black_motor2, HIGH);
break;
case Up:
digitalWrite(Yellow_motor1, LOW);
digitalWrite(Yellow_motor2, HIGH);
digitalWrite(Black_motor1, HIGH);
digitalWrite(Black_motor2, HIGH);
break;
case Down:
digitalWrite(Yellow_motor1, HIGH);
digitalWrite(Yellow_motor2, HIGH);
digitalWrite(Black_motor1, HIGH);
digitalWrite(Black_motor2, LOW);
break;
case Pause:
digitalWrite(Yellow_motor1, LOW);
digitalWrite(Yellow_motor2, LOW);
digitalWrite(Black_motor1, LOW);
digitalWrite(Black_motor2, LOW);
break;
}
receiver.resume();
}
}
However, upon connecting all the components and uploading the program to the microcontroller, there are some issues. I have tried browsing everything from this forum, to stackoverflow, to Github, but I haven't been able to find my issues I'm having, so I'm hoping that someone can help me out. The issues I am having are:
-Only one of the motors spins when buttons are pressed. Specifically the motor labelled "Yellow_motor". It only spins counterclockwise and only when "Yellow_motor2" is designated as HIGH, so during cases Next, Up, and Down.
-Once the motor is spinning, the IR receiver doesn't realize that buttons are being pressed
Additional Information: I confirmed with direct battery hookup that the black motor doesn't spin at all. I also tried using different pins for the motors on the board to no avail. Could the black motor be effecting the circuit and therefore screwing everything up? Would that effect the IR receiver once the yellow motor is spinning? Why does the yellow motor only spin counterclockwise?
Any information you can provide me will be greatly appreciated. Thank you so much in advance!