Arduino Motor Shield Speed Control

Talk about Arduino board, sheilds. Sharing Arduino projects, program, problems, solutions, suggestions..... many more, all are welcome.

Arduino Motor Shield Speed Control

Postby philli3 » Fri Apr 20, 2012 12:27 pm

Hi all, I am facing this problem while trying to get motor speed control done on my arduino project.

I have created a java applet to send these signals to my arduino board:
w - Forward
a - Left
s - Reverse
d - Right
z - Low Speed
x - Normal Speed
c - High Speed

how can i assign each speed to my determined direction control in my arduino codes ?

this is how my codes look like:

int value = 255;

void loop(){
char id = Serial.read();

switch (id){
//Move Forward
case 'w':
digitalWrite(M1,HIGH);
digitalWrite(M2,LOW);
// analogWrite(E1,value);
// analogWrite(E2,value);
Serial.println("Move Forward");
break;

case 'z':
Serial.println("Low Speed");
analogWrite(E1,value-100);
analogWrite(E2,value-100);
break;

All the codes are working, just that i dont know how to assign the speed control to each direction.
Thanks in advance.
philli3
Newbie
 
Posts: 9
Joined: Tue Feb 21, 2012 12:46 am

Re: Arduino Motor Shield Speed Control

Postby ABSF » Sat Apr 21, 2012 5:36 am

At case 'z'

philli3 WROTE:case 'z':
Serial.println("Low Speed");
value = value-100;
analogWrite(E1,value);
analogWrite(E2,value);
break;


Then the speed value at case ''w' would be the current value.
If you need different speeds for w, a, s, d then you'll have to define 4 different speed values for each direction.

Allen
The next war will determine NOT who is right BUT what is left.
User avatar
ABSF
Professional
 
Posts: 810
Joined: Wed Nov 10, 2010 9:32 am
Location: E Malaysia

Re: Arduino Motor Shield Speed Control

Postby philli3 » Sat Apr 21, 2012 10:44 pm

Million thanks for the information

I have found what my problem is, thanks again
philli3
Newbie
 
Posts: 9
Joined: Tue Feb 21, 2012 12:46 am


Return to Arduino Based

Who is online

Users browsing this forum: No registered users and 18 guests

cron