Go Down

### Topic: DC Motor and Potentiometer positioning (Read 3364 times)previous topic - next topic

#### THX_RoG

#15
##### Mar 09, 2013, 06:05 pmLast Edit: Mar 09, 2013, 08:14 pm by THX_RoG Reason: 1
dude ur amazing i just looking for the deadband code
Code: [Select]
`void Motor(){ val1=analogRead(Poti1); val2=analogRead(Poti2); if ((val1>val2)&&(val1>minval)) { Motor_1_3(); } if ((val1<val2)&&(val1<maxval)) { Motor_2_4(); } if ((val1=val2)||(val1=minval)||(val1=maxval)) { Motor_OFF(); }}`
one question can i put val = analogread to a different void or this wouldn't work
UNO,MEGA2560,MEGA2560
Killed:UNO, MEGA2560, ... More to come

#### zoomkat

#16
##### Mar 10, 2013, 12:35 am
Quote
one question can i put val = analogread to a different void or this wouldn't work

What happened when you tried it?
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

#### THX_RoG

#17
##### Mar 10, 2013, 09:35 am
nothing my values wear 0 on both potentiometers
now have issue withe the deadband when i use
Code: [Select]
`if (val1 < (targetval1-10) | val1 > (targetval1+10){if ((val1>val2)&&(val1>minval)) { Motor_1_3();                         targetval1=val1 }`
my code works one whey
UNO,MEGA2560,MEGA2560
Killed:UNO, MEGA2560, ... More to come

#### AWOL

#18
##### Mar 10, 2013, 10:08 am
There's a difference between bit wise OR |  and (no pun intended) logical OR ||
"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

#19
##### Mar 10, 2013, 10:55 am
still no use the same problem
UNO,MEGA2560,MEGA2560
Killed:UNO, MEGA2560, ... More to come

#### AWOL

#20
##### Mar 10, 2013, 02:43 pm
Still no code
"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

#21
##### Mar 10, 2013, 03:45 pm
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

#22
##### Mar 10, 2013, 06:04 pm
The below might need some attention, depending on just what you are trying to accomplish.

Code: [Select]
`if ((targetval1=val2)||(val1=minval)||(val1=maxval))`
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

#### THX_RoG

#23
##### Mar 10, 2013, 06:45 pm
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

#24
##### Mar 10, 2013, 07:09 pm
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
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

Go Up

Please enter a valid email to subscribe