Hello, I am having trouble with a project i have. I am using arduino uno with the arduino motor shield r3 and an infrared receiver.
The idea is that i control the rover with the remote. I have a library called IRremote that helps me with getting remote codes.
The problem is, the motors for the wheels don’t move at all. I have tested the wires and all the connections are well connected and insulated. The lights that are next to the motor ports on the motor shield stay off when they are supposed to be on.
/*
* Sketch modified by Enjoying Electronics: http://www.instructables.com/member/Enjoying+Electronics/
Code based off of:
* IRremote
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* For details, see http://arcfn.com/2009/08/multi-protocol-infrared-remote-library.html
* Special thanks to dablondeemu http://www.instructables.com/member/dablondeemu/
* and his instructable listed below, IR Remote Controlled Color Changing Cloud (Arduino)
* http://www.instructables.com/id/IR-Remote-Controlled-Color-Changing-Cloud-Arduino/
* Lets get started:
The IR sensor's pins are attached to Arduino as so:
Pin 1 to Vout (pin 11 on Arduino)
Pin 2 to GND
Pin 3 to Vcc (+5v from Arduino)
*/
/*******************CODE BEGINS HERE********************/
#include <IRremote.h>
int IRpin = 2;
IRrecv irrecv(IRpin);
decode_results results;
int infraredCode;
int Speed;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
//Setup Channel A
pinMode(12, OUTPUT); //Initiates Motor Channel A pin
pinMode(9, OUTPUT); //Initiates Brake Channel A pin
//Setup Channel B
pinMode(13, OUTPUT); //Initiates Motor Channel A pin
pinMode(8, OUTPUT); //Initiates Brake Channel A pin
Speed = 100;
}
void loop() {
if (irrecv.decode(&results)) {
infraredCode = results.value;
Serial.println(infraredCode); // Print the Serial 'results.value'
irrecv.resume(); // Receive the next value
}
Serial.println(infraredCode);
if (infraredCode == -23971) {
Serial.println("Forward Button Pressed");
digitalWrite(12, HIGH);
digitalWrite(9, LOW);
analogWrite(3, Speed);
digitalWrite(13, HIGH);
digitalWrite(8, LOW);
analogWrite(11, Speed);
}
if (infraredCode == -15811) {
Serial.println("Middle Button Pressed");
digitalWrite(12, HIGH);
digitalWrite(9, HIGH);
analogWrite(3, 0);
digitalWrite(13, HIGH);
digitalWrite(8, HIGH);
analogWrite(11, 0);
}
}
Someone please help!