fihj
December 19, 2021, 12:35pm
1
İm trying to make an ir controlled car
its work but the leftback motor is not working
im sure about the code and the connections in another code its working but with out ir controll
where is the problem?
Here is my code:
#include <AFMotor.h>
#include <IRremote.h>
AF_DCMotor motor1(1, MOTOR12_1KHZ);
AF_DCMotor motor2(2, MOTOR12_1KHZ);
AF_DCMotor motor3(3, MOTOR34_1KHZ);
AF_DCMotor motor4(4, MOTOR34_1KHZ);
IRrecv IR(A5);
decode_results result;
int Speed = 250;
#define up 16718055
#define down 16730805
#define left 16716015
#define right 16734885
#define Stop 16726215
void setup() {
Serial.begin(9600);
motor1.setSpeed(250);
motor2.setSpeed(250);
motor3.setSpeed(250);
motor4.setSpeed(250);
IR.enableIRIn();
}
void loop() {
if (IR.decode(&result)) {
Serial.println(result.value);
IR.resume();
}
delay(100);
if (result.value == up ) {
motor1.run(FORWARD);
motor2.run(FORWARD);
motor3.run(FORWARD);
motor4.run(FORWARD);
} else if (result.value == down ) {
motor1.run(BACKWARD);
motor2.run(BACKWARD);
motor3.run(BACKWARD);
motor4.run(BACKWARD);
} else if (result.value == Stop) {
motor1.run(RELEASE);
motor2.run(RELEASE);
motor3.run(RELEASE);
motor4.run(RELEASE);
} else if (result.value == left) {
motor1.run(FORWARD);
motor2.run(BACKWARD);
motor3.run(FORWARD);
motor4.run(BACKWARD);
} else if (result.value == right) {
motor1.run(BACKWARD);
motor2.run(FORWARD);
motor3.run(BACKWARD);
motor4.run(FORWARD);
}
}
fihj:
Here is my code:
Did you get a warning pop-up when you posted your code without using code tags ?
Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'
Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination
See also FAQ - Arduino Forum for general rules on forum behaviour and etiquette.
Hello,
Welcome to the Arduino Forum.
This guide explains how to get the best out of this forum. Please read and follow the instructions below.
Being new here you might think this is having rules for the sake of rules, but that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of posts while we try to get you to tell us what we need in order to help you, which is fru…
Your post was MOVED to its current location as it is more suitable.
no ??? What ?
Hi
No?
Oh my God............
Now a question:
If motor1-2 is on the left then motor3-4 is on the right, but if motor1-2 is on the right then motor3-4 is on the left.
I'm right so far....
ruilviana:
I'm right so far....
You are right if I am facing you.
ruilviana:
no ??? What ?
I imagine it means "no, I didn't get a warning pop-up"
Hi
thanks for your attention.
I also think I answered the reason for the no, but I didn't understand was the ? after the no.
Att:
I interpreted the "no?" as "no, should I have done ?"
fihj
December 19, 2021, 2:40pm
10
i didnt get any warning
and the leftback motor is 2 the left side is 1 and 2 so you are wrong
What about this test? Disconnect the working motor and see if the other wakes up?
Schematics could be useful. Power issues often causes problems like Yours.
fihj
December 19, 2021, 4:20pm
12
OKAY ill try it when the car get charge
Okey.
If I would be facing this issue I would make a test sketch, cutting away all other code than just the motor control.
In loop exercise each motor, one at the time, then the motor combinations You need like 2 at the same time, or even all 4.
system
Closed
June 17, 2022, 9:07pm
15
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.