Hi everyone i am trying to make a ir controlled robot using ir remote and l293d motor driver shield
here is my code-
#include <AFMotor.h>
#include <IRremote.h>
#define FORWARD 16718055
#define BACK 16730805
#define LEFT 16716015
#define RIGHT 16734885
#define STOP 16726215
#define RECV_PIN 10
AF_DCMotor motor1(3);
AF_DCMotor motor2(4);
IRrecv irrecv(RECV_PIN);
decode_results results;
unsigned long val;
unsigned long preMillis;
void forward()
{
motor1.run(FORWARD);
motor2.run(FORWARD);
Serial.println("go forward!");
}
void back()
{
motor1.run(BACKWARD);
motor2.run(BACKWARD);
Serial.println("go back!");
}
void left()
{
motor1.run(BACKWARD);
motor2.run(FORWARD);
Serial.println("go left!");
}
void right()
{
motor1.run(FORWARD);
motor2.run(BACKWARD);
Serial.println("go right!");
}
void stop()
{
motor1.run(RELEASE);
motor2.run(RELEASE);
Serial.println("STOP!");
}
void setup()
{
Serial.begin(9600);
stop();
irrecv.enableIRIn();
motor1.run(RELEASE);
motor2.run(RELEASE);
}
void loop() {
if (irrecv.decode(&results)){
preMillis = millis();
val = results.value;
Serial.println(val);
irrecv.resume();
switch(val){
case FORWARD: forward(); break;
case BACK: back(); break;
case LEFT: left(); break;
case RIGHT: right(); break;
case STOP: stop(); break;
default: break;
}
}
else{
if(millis() - preMillis > 150){
stop();
preMillis = millis();
}
}
}
but for some reason the motors aren't working.
yes i am giving extra power supply through the shield but then also they are not working.
PLEASE HELP