Standard motor reading values from a device


I have a doubt and i need help! I have a standard motor and i want it to read signals from a device(via arduino) which jumps from values 0 to 100, i.e. it can be 23 one sec and the other 44.
What i am trying to do, is to make the motor move when the signal is between 70 to 100. I tried map function like:
val= map(val, 70,100,0,180); //val is the signal coming which ranges from 0 to 100, but i want to only have the motor respond when its between 70 to 100.
delay(1000); //i want a delay between each position.

Here, the motor moves 180 but remains there until the next value change. Can i have a way where it moves constantly between 0 to 180, as the value increases from 70 to 100.

Also, i want to know a way where it moves clockwise when the signal increases and goes anticlockwise when the signal decreases.


And the problem is the signal is such that it remains a value, for eg. 45 for some time and then jumps up to say 67 or comes down to 0.

How can i have the motor respond to such an erratic behavior of the signal? I just want it to rotate clockwise from 0 to 180 GRADUALLY as the signal value reaches 70 until 100.

And then motor comes back to 0 ONLY when the signal value reaches 100.


Thank you

I presume “standard motor” means “standard servo”?

To only respond to a given range, test it:

if (value >= 70 && value <= 100)
  servo.write (map (value, 70, 100, 0, 180)) ;

Oops sorry yes, i meant standard servo.

And how do i make it rotate only clockwise( in one direction) and come back to the starting when the signal value=100?

Thanks for the reply. :slight_smile: