hello
can somebody please help me with my project. my project is to control my car with 2 motors with my PC
for example
if I press the button W on my keyboard my car will go forward
if I press the button A on my keyboard my car will go left
if I press the button D on my keyboard my car will go right
What have you got?
You need two motor drivers.
You need some sort of power source. You need some sort of program in an arduino.
Your question is very vague.
Note we do not write code for you here, we help you write it.
first of all thanks for reading
i wrote a code but i know that its wrong because im pretty new with the language C but i know the language java using the program BleuJ
my code for my program to control is :
int motorpin=5;
int motorpinA=2;
void setup ()
{
Serial.begin(9600);
pinMode (motorpin,OUTPUT);
pinMode (motorpinA,OUTPUT);
}
void loop()
{
int w;
scanf("%d", w);
if(w==8)
{
digitalWrite(motorpin,LOW);
digitalWrite(motorpinA,HIGH);
printf("the robot is running forward");
}
}
You'll have problems with scanf and printf.
Try sscanf and Serial.print
It is normal to have two outputs to drive a motor. One for on / off and the other for direction.
What do you have as a motor driver?
to AWOL you mean like this:
int w;
sscanf ("%d", w);
if(w==8)
{
digitalWrite(motorpin,LOW);
digitalWrite(motorpinA,HIGH);
Serial.print("the robot is running forward");
}
}
and again i'm pretty new with C so if you can translate the commend to java it will be great
to Grumpy_Mike if you mean what my motor driver is :
DAGU robot
DG01D 48:1
mini DC gearBox
there is a sticker on my motor and that is what its says
but if you dont mean that please explain what you mean
thanks
to AWOL you mean like this:
No, sscanf needs a source buffer.
A motor can not be attached directly to an Arduino output pin. You need some electronics to drive it. What do you have to do this?
hello again im sorry for not answering before.
to AWOL what is a buffer can you please give example thanks you
When you have code on an Arduino coming in from the serial input of the serial monitor then you do not use sscanf you use the built in Serial library:-
hello again im sorry for not answering before..
to Grumpy_Mike
if you mean my my board that connected to my PC his name is UNO but i dont know his specific name but i think that tomorrow i could tell you the name
but for now can somebody help me with the code
thanks
if you mean my my board that connected to my PC his name is UNO
No the UNO is the Arduino.
You then connect the Arduino to something and then connect the motors to that "something".
What is that something?
If that "something" is nothing then you have probably damaged your Arduino.
but for now can somebody help me with the code
I have helped you, read that link!