acemax
April 20, 2023, 1:18am
1
// C++ code
//
define M1A 13
define M1B 12
define M2A 10
define M2B 9
define MAIN1 2
define MAIN2 3
void forward(unsigned long ms){
digitalWrite(M1A, HIGH);
digitalWrite(M1B, LOW);
digitalWrite(M2A, HIGH);
digitalWrite(M2B, LOW);
delay(ms);
}
void setup()
{//Setting all up as OUTPUTs
pinMode(MAIN2, OUTPUT);
pinMode(M1A, OUTPUT);
pinMode(M1B, OUTPUT);
pinMode(M2A, OUTPUT);
pinMode(M2B, OUTPUT);
}
void loop()
{
digitalWrite(M1A, LOW);
digitalWrite(M1B, LOW);
digitalWrite(M2A, LOW);
digitalWrite(M2B, LOW);
digitalWrite(MAIN1, HIGH); //Turning on the two GearMotors
digitalWrite(MAIN2,HIGH);
forward(2000);
delay(2000);
forward(2000)
;digitalWrite(M1A, HIGH);
digitalWrite(M1B, LOW);
digitalWrite(M2A, LOW);
digitalWrite(M2B, HIGH);
delay(2000);
digitalWrite(M1A, LOW);
digitalWrite(M1B, HIGH);
digitalWrite(M2A, HIGH);
digitalWrite(M2B, LOW);
delay(2000);
digitalWrite(M1A, LOW);
digitalWrite(M1B, HIGH);
digitalWrite(M2A, LOW);
digitalWrite(M2B, HIGH);
delay(2000);
}
Please edit your post to add code tags.
For informed help, please read and follow the instructions in the "How to get the best out of this forum" post, linked at the head of every forum category.
In addition to @jremington response go through it
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…
1 Like
acemax
April 20, 2023, 1:28am
5
This code was made to operate 2 gear motors to create a car that demonstrates the capability to turn left, and right as well as go backward and forwards for further info on code and circuitry access link to Tinkercad on the original post (at the bottom).
LarryD
April 20, 2023, 1:34am
6
Nobody here is going to sign up for Tinkercad to answer your question.
Tell us what is not working ?
HI,
Export images from your Tinkercad project as jpg images and post them in a new post in this thread.
To add code please click this link;
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…
Thanks.. Tom..
1 Like
acemax
April 21, 2023, 2:11am
8
Sorry got this working but for some reason, it requires a laptop connection as a power source I need it to work off the 9V battery instead as it must operate independently. I'm not sure if the issue may be in the battery pack itself or the overall circuitry. Thanks for your help in advance.
amitf
April 21, 2023, 2:33am
10
You haven't connected positive of battery to vin pin of Arduino
acemax
April 21, 2023, 3:15am
11
Once again I would like your advice as I am still unable to operate this car.
amitf
April 21, 2023, 7:19am
12
Try with a better battery. Or you can use two seperate 9v battery to power motor and Arduino
Can you post the pic of your actual circuit
pert
Split this topic
October 28, 2023, 8:47am
14
2 posts were split to a new topic: Arduino car problems
system
Closed
April 25, 2024, 8:47am
15
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.