i need the CODE for an RF robot with L923D (no motor shield) and receiver YK04

Hello,
i have tried for a long time to write and correct the code but its not working.
my project is an RF robot with l923d(no motor shield). leg 1,8,9,16 and one for the battery and one from the receiver are connecting to + (i soldered them on pins and wired another one to the arduino 5v).
leg 4,5,12,13 and and the battery and receiver are connecting to the - (i soldered them to pins,not the same pins as the + and wired another to the GND in arduino).
I'm using the 6 legs of YK04 RECEIVER and they are:5v(connects to the + i mensioned earlier),GND(connects to the - i mesioned earlier), and another 4 buttons (D0-D3).
D0 is connected to the arduino to the digital ports number 2 , D1 is connected to number 3, D2 is connected to number 4, and D3 is connected to number 5.
motor 1 legs are wired up from leg 2,7 in the l923d and are going to to the digital pins 6,7 and motor 2 is wired up from legs 15,10 of the l923d and are going to pins of the arduino number 9,10.

i tried to do it the code by myself but its still not working.
can anyone help me and send here the code for the exacly same legs as i did ? (remember no motor shield just l923d and yk04 receiver with controller with 4 buttons)
i dont have much time i have to finish it in a few days.
thanks a head and good day.

#include <AFMotor.h>

AF_DCMotor motor1(6,7);
AF_DCMotor motor2(9,10);
int A = 2;
int B = 3;
int C = 4;
int D = 5;

void setup() {
pinMode (A0,INPUT);
pinMode (A1,INPUT);
pinMode (A2,INPUT);
pinMode (A3,INPUT);
}
void loop (){

A=digitalRead(A0);
B=digitalRead(A1);
C=digitalRead(A2);
D=digitalRead(A4);
if(A==1&&B==0&&C==0&&D==0)
{

motor2.run(FORWARD);

motor2.setSpeed(255);

motor1.run(BACKWARD);

motor1.setSpeed(255);

delay(2000);
}
else
{
motor1.run(RELEASE);
motor2.run(RELEASE);
}

if(A==0&&B==1&&C==0&&D==0)

{
motor1.run(FORWARD);

motor1.setSpeed(255);

motor2.run(BACKWARD);

motor2.setSpeed(255);
delay(2000);
}

else
{
motor1.run(RELEASE);
motor2.run(RELEASE);
}

if(A==0&&B==0&&C==1&&D==0)

{
motor1.run(BACKWARD);

motor1.setSpeed(255);
delay(1000);
}
else
{
motor1.run(RELEASE);

}

if(A==0&&B==0&&C==0&&D==1)

{
motor2.run(FORWARD);
motor2.setSpeed(255);
delay(1000);
}
else
{

motor2.run(RELEASE);
}
}

thats what i wrote but its not working, remember i am not using a motor shield plz tell me what is wrong regarding what the pins and legs i told you about earlier

thats what i wrote but its not working

That tells is NOTHING useful. The code does something, or your hardware is not wired properly.

You expect it to do something.

You need to tell us what it ACTUALLY does, and how that differs from what you expect.

AND, post a schematic!

the RF ROBOT is actually a Car that supose to move forward backward right and left.
when i press A on my rf controller (have 4 buttons) the reciver will get the singal both of the motors will turn right.
when i press B on my rf controller the motors will go left.
when i press C on my rf controller the motors will go backwards.
when i press D on my rf controller the motors will go forward.
that was i expected from them to do but they are not moving at all and my hardware is wired properly and tight.
about the schematic i dont have a picture but its need to work like that: RF transmitter giving order, coder, receiver get it,doing one of the movement i mensioned earlier in this comment, and last decoder.
thats about it its supose to be very easy but its hard to because i am new but i have to comlete this project.
so here a explained here everything can you write a code for me ? plz
thanks.

that was i expected from them to do but they are not moving at all and my hardware is wired properly and tight.

Take EVERYTHING out of the sketch that has nothing to do with actually making ONE motor move. Do not read any switches. Do not have ANY conditionals. Simply set the pins needed to make ONE motor move.

If the motor doesn't move, your claim that "my hardware is wired properly and tight." is nonsense.

can you write it for me ? plz
i have to complete it quickly, and finish it.
how can i declare 2 motors (motor 1 legs 6,7 motor 2 legs 9,10).
and what next plz help me and write for yourself its should be easy for you, plz help me and write it and send it here.

This is not a free code writing service. We’re happy to help YOU get YOUR code working but that’s all. And if you’ve left yourself too little time to finish the job I have to say that really is not our problem.

But looking at your code, why are A, B, C and D defined as the pin numbers you say the receiver connects to but then you set as input and read from completely different pins A0 - A4. And even worse you put what you read into variables A, B, C and D. That makes no sense.

And if you have no motor shield why are you using AFMotor.h which works with the old Adafruit Motor Shield? What makes you think that it will work with a bare L293?

So the code is definitely not right and my guess is that the hardware you don’t have a schematic for is not right either.

Steve

  1. So how am i supose to declare A,B,C,D (which are the 4 options that are gets from the 4 buttons controller that causes the movement of the car).
  2. about A0-A4 Ok i realize that, i defined each one of them to write next each one the pin the reciver is connects to the digital pins. if its not supose to be like that then how ?
  3. how do i declare the two motors?int?#define ? how ? (motor 1- pin 6,7 motor 2-pin 9,10)
  4. about the reciver about A,B,C,D how am i supose to set them ? if not as an input then how ? (A,B,C,D are supose to reed the orders they get from the RF TRANSMITTER).

please tell me how to correct my code, i mean if you see more problems.

You said
"I''m using the 6 legs of YK04 RECEIVER and they are:5v(connects to the + i mensioned earlier),GND(connects to the - i mesioned earlier), and another 4 buttons (D0-D3).
D0 is connected to the arduino to the digital ports number 2 , D1 is connected to number 3, D2 is connected to number 4, and D3 is connected to number 5."

So why are you trying to read the information from the receiver using pins A0-A4. Is there anything connected to those pins?

And you can't use the same variables A-D both to hold the pin numbers AND the data you read from those pins. If you don't understand that you have no chance of getting anything to work.

I can't help with the motors. I've never used a L239D without a shield.

Steve

The L293D might not even work with the OP's motors. It is ancient technology and very limited.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

A schematic is the important part we need, include how you are powering the robot and pictures of your project.

Thanks.. Tom... :slight_smile:

I already told you i realize my mistak about A0-A4, forget about it.
can someone tell me how can i declare my 2 DC motors ?
then what shoud i do with the D0-D3 (Reciver pins) how should i declare them. i want them to receive the signal from my RF transmitter and play the following orders (A=forward, b=backward, c=right, d=left).
then can you tell me how? because you guys are not answering my questions i reading about it in the internet and i dont find information about the receiver order or code or anything, so i came to you.
please answer my question.
for each pin i wrote its pin so the arduino will realize it and afterwards as an input for getting the transmitter signal and so the motors should be the output right ?
so please i gave you information how and what should i do it?

If you have made changes then post your latest code. We don't like trying to guess what you're asking us to help with. Have you taken AFMotor.h out yet?

You won't show us a schematic but you say you know all the hardware is connected up right. So that must mean that you've tried some code that makes the motors run through the L239, right? Show us that code as well. Or if you've never seen the motors run then you definitely aren't sure the hardware is right.

Somewhere in all your confused talk about legs, pins, ports and buttons I think you said you were powering the L239 from the Arduino 5V pin. If that is right then that may explain why the motors have never run. That 5V pin can't deliver much current without damaging the Arduino and the L239 will lose 2-3V leaving you only 2V, which isn't enough to run motors.

So another question. How is this robot powered. Battery? What battery, type, voltage etc.? Something else? What?

Steve

DarKnight1:
I already told you i realize my mistak about A0-A4, forget about it.
can someone tell me how can i declare my 2 DC motors ?

Hi,
I gather this is for a school project.
So STOP.
PULL YOURSELF TOGETHER, you ask for our help, we are trying to give it.
If it is a school project, you must have to produce construction details.
SO, STOP, get out pen/pencil and paper and draw a legible circuit diagram of your complete circuit, showing pin numbers and names.
STOP and post the code you now have so we can HELP.
This will help use to modify you code.
Now some questions;

  • Have you written code JUST to run the motors forward and backwards.
  • Have you tested the output of your remote receiver to check it works?
  • Have you written code JUST to check that the code responds to the receiver?
  • What are you motors? Post a picture please.
  • What are you using to power the project? Include in circuit diagram please.
  • What level of education is this project at?
  • What have you been taught in class about Arduino, coding and hardware?
  • Why have you not asked your teacher/tutor/instructor for help, if they know you are looking for help, it is not a bad thing. I means you are prepared to ask questions.

Please answer the questions above.

You at the moment have to debug and fix your project.
Look at my sidebar, it is my job to debug and repair, actually 80% repair with no service info.
BUT if needed I reverse engineer to get a basic schematic, it takes time but can save wasting 10 x that time in barking up the wrong tree.

Here I am in worse situation where I have no hands on your project, in fact "we" as forum members have no hands on your project, and we are trying to LOGICALLY proceed through your problem.

Unfortunately I cannot reverse engineer your project, your pin to leg description is not enough we need your eyes to come up with a circuit diagram so we can advise on code and see if the code will work with your hardware.
Thanks.. Tom.... :slight_smile: