Go Down

Topic: DC Motor and Potentiometer positioning (Read 1 time) previous topic - next topic

AWOL

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

THX_RoG

here is the code
Code: [Select]

void Motor()
{
val1=analogRead(Poti1);
val2=analogRead(Poti2);
targetval1=(val1<(val1-10)||val1>(val1+10));
if ((val1>val2)&&(val1>minval))
{
Motor_1_3();
}
if ((val1<val2)&&(val1<maxval))
{
Motor_2_4();
}
if ((targetval1=val2)||(val1=minval)||(val1=maxval))
{
Motor_OFF();
}
}
UNO,MEGA2560,MEGA2560
Killed:UNO, MEGA2560, ... More to come

zoomkat

The below might need some attention, depending on just what you are trying to accomplish.

Code: [Select]
if ((targetval1=val2)||(val1=minval)||(val1=maxval))
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

THX_RoG

my minval is 10 and my maxval 1000 thats because i don't want damage the potentiometer so im using this as a stop point
it seems to me as hes in loop with this part
Code: [Select]

             if ((val1>val2)&&(val1>minval))
{
Motor_1_3();
}
if ((val1<val2)&&(val1<maxval))
{
Motor_2_4();
}

UNO,MEGA2560,MEGA2560
Killed:UNO, MEGA2560, ... More to come

zoomkat

Something that may/may not make a difference depending on what you are trying to do.

http://arduino.cc/en/Reference/Assignment

http://arduino.cc/en/Reference/If
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

Go Up