I'm trying to make a 4WD car using a arduino uno rev 3 and a l293d motor shield. I'm trying to use a rc receiver to control it but I haven't been able to find anything. I'm a beginner also. And I want it to turn on a dime.
Try here
The only thing I have been able to find is bluetooth cars but bot any rc transmitter and receiver.
Did you actually try the link you were given? The one that finds thousands of Arduino projects reading data from RC receivers?
If you have already found cars running on data received from Bluetooth then it shouldn't be exactly difficult to replace the Bluetooth data with data from an RC receiver. Give it a try.
Steve
would the code for the tutorial I'm using work with a receiver? How To Make A Simple DIY Arduino Bluetooth Controlled Car At Home - YouTube
flyingraccons2, rather than posting a link to a video, post the code you want us to look at. Use code tags. Like this:
//Arduino Bluetooth Controlled Car
//Before uploading the code you have to install the necessary library
//Note - Disconnect the Bluetooth Module before hiting the upload button otherwise you'll get compilation error message.
//AFMotor Library https://learn.adafruit.com/adafruit-motor-shield/library-install
//After downloading the library open Arduino IDE >> go to sketch >> Include Libray >> ADD. ZIP Libray >> Select the downloaded
//ZIP File >> Open it >> Done
//Now You Can Upload the Code without any problem but make sure the bt module isn't connected with Arduino while uploading code
#include <AFMotor.h>
//initial motors pin
AF_DCMotor motor1(1, MOTOR12_1KHZ);
AF_DCMotor motor2(2, MOTOR12_1KHZ);
AF_DCMotor motor3(3, MOTOR34_1KHZ);
AF_DCMotor motor4(4, MOTOR34_1KHZ);
char command;
void setup()
{
Serial.begin(9600); //Set the baud rate to your Bluetooth module.
}
void loop(){
if(Serial.available() > 0){
command = Serial.read();
Stop(); //initialize with motors stoped
//Change pin mode only if new command is different from previous.
//Serial.println(command);
switch(command){
case 'F':
forward();
break;
case 'B':
back();
break;
case 'L':
left();
break;
case 'R':
right();
break;
}
}
}
void forward()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(FORWARD); //rotate the motor clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(FORWARD); //rotate the motor clockwise
motor3.setSpeed(255);//Define maximum velocity
motor3.run(FORWARD); //rotate the motor clockwise
motor4.setSpeed(255);//Define maximum velocity
motor4.run(FORWARD); //rotate the motor clockwise
}
void back()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(BACKWARD); //rotate the motor anti-clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(BACKWARD); //rotate the motor anti-clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(BACKWARD); //rotate the motor anti-clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(BACKWARD); //rotate the motor anti-clockwise
}
void left()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(BACKWARD); //rotate the motor anti-clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(BACKWARD); //rotate the motor anti-clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(FORWARD); //rotate the motor clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(FORWARD); //rotate the motor clockwise
}
void right()
{
motor1.setSpeed(255); //Define maximum velocity
motor1.run(FORWARD); //rotate the motor clockwise
motor2.setSpeed(255); //Define maximum velocity
motor2.run(FORWARD); //rotate the motor clockwise
motor3.setSpeed(255); //Define maximum velocity
motor3.run(BACKWARD); //rotate the motor anti-clockwise
motor4.setSpeed(255); //Define maximum velocity
motor4.run(BACKWARD); //rotate the motor anti-clockwise
}
void Stop()
{
motor1.setSpeed(0); //Define minimum velocity
motor1.run(RELEASE); //stop the motor when release the button
motor2.setSpeed(0); //Define minimum velocity
motor2.run(RELEASE); //rotate the motor clockwise
motor3.setSpeed(0); //Define minimum velocity
motor3.run(RELEASE); //stop the motor when release the button
motor4.setSpeed(0); //Define minimum velocity
motor4.run(RELEASE); //stop the motor when release the button
}
Can that be made to work with an RC receiver? Sure!
What hardware are you using? 4 motor/wheels fixed to the chassis like in the video?
yeah
I only want to change how to control it
flyingraccoons2:
I only want to change how to control it
Go ahead - you don't need to ask permission.
so it would work? I just have to plug in 2 channels from the receiver and run the same code? I'm new so I have literally no idea how to do this. Thanks as well.
Plug in two channels and measure the pulse width on each.
How you interpret the width values is up to you.
what pins should I connect the channels to?
Well, I'd leave 0 and 1 for their important uses, so, how about 2 and 3?
thanks.
does this sound right? plug 5v and ground from arduino into receiver, plug channels 2 and 3 into 2 and 3 on the arduino/motor shield and upload the code?
Why not channels one and two?
I meant 1 and 2 channels. sorry
flyingraccoons2:
and upload the code?
The code that you have modified, right?
In the first reply was a helpful link to a whole lot of examples of reading RC receivers.
That code is different than serial communication over BLE.
Have you read any of the links from the first response?
I would try, without any of the code for the motors, to read the receiver and simply print the values to the serial monitor.
Then decide how you will add them to the code for your motor drivers.
I found a really helpful link. Thanks for the first link. It finally proved useful.