Hi, I have recently started a minor robotics project where a sumo bots wheels are controlled through an IR remote and receiver. The project works fine until I remove the wire connecting the computer and MEGA board. Then whenever the IR remote is pressed the arduinos L light is lit up instead of the TX light and the project does nothing. I can confirm that the project has power.
const int irReceiverPin = 20;
AF_DCMotor motorTwo(2, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motorOne(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm
AF_DCMotor motorThree(3, MOTOR12_64KHZ); // create motor #2, 64KHz pwm
AF_DCMotor motorFour(4, MOTOR12_64KHZ); // create motor #1, 64KHz pwm
IRrecv irrecv(irReceiverPin); //Creates a variable of type IRrecv
decode_results results;
void setup() {
Serial.begin(9600); //initialize serial monitor
irrecv.enableIRIn(); //enable ir receiver module
Serial.print(“Motor test!”);
motorOne.setSpeed(250); // set the speed to 200/255
motorTwo.setSpeed(250); // set the speed to 200/255
motorThree.setSpeed(250); // set the speed to 200/255
motorFour.setSpeed(250); // set the speed to 200/255
}
void loop() {
if (irrecv.decode(&results)) //if the ir receiver module receiver data
{
Serial.print("irCode: “); //print"irCode: "
Serial.print(results.value, HEX); //print the value in hexdecimal
Serial.print(”, bits: “); //print” , bits: "
Serial.println(results.bits); //print the bits
irrecv.resume(); // Receive the next value
}
delay(600); //delay 600ms
if(results.value == 0xFF18E7) // 2
{
motorOne.run(FORWARD); // turn it on going forward
motorTwo.run(FORWARD); // turn it on going forward
motorThree.run(BACKWARD); // turn it on going forward
motorFour.run(BACKWARD); // turn it on going forward
}
else if(results.value == 0xFF4AB5) // 8
{
motorOne.run(BACKWARD); // turn it on going forward
motorTwo.run(BACKWARD); // turn it on going forward
motorThree.run(FORWARD); // turn it on going forward
motorFour.run(FORWARD); // turn it on going forward
}
else if(results.value == 0xFF38C7) // 5
{
motorTwo.run(RELEASE); // turn it on going forward
motorOne.run(RELEASE); // stopped
motorThree.run(RELEASE); // turn it on going forward
motorFour.run(RELEASE); // turn it on going forward
}
else if(results.value == 0xFF5AA5) // 6
{
motorTwo.run(RELEASE); // turn it on going forward
motorOne.run(FORWARD); // stopped
motorThree.run(RELEASE); // turn it on going forward
motorFour.run(BACKWARD); // turn it on going forward
}
else if(results.value == 0xFF10EF) // 4
{
motorTwo.run(FORWARD); // turn it on going forward
motorOne.run(RELEASE); // stopped
motorThree.run(BACKWARD); // turn it on going forward
motorFour.run(RELEASE); // turn it on going forward
}else{}
}
There might not be enough current to power all of the chips and modules connected to your board. Connecting an external power source (via the VIN pin or elsewhere) to supply more current might solve the issue, although I wouldn’t consider myself an Arduino expert like the other two people in this thread.