Warning

 

Close
Confirm Action

Are you sure you wish to do this?

Cancel Confirm
AR15.COM
7/30/2017 9:50:24 PM EDT
Anybody know this stuff?

I'm trying to map a digital input to a servo.


I have the input working ( I can see the output on the serial monitor)

I have the servo working



But I dont know shit about C and have no idea how to map them together.


If anyone can teach me this I'll buy you a membership, or whatever you want really as long as we agree beforehand.


Thanks!!!
7/30/2017 10:07:15 PM EDT
[#1]
Google fu is your friend, there are probably many code examples out there. Not a programmer by trade and don't have any experience with machine interfaces!

I have a pcarduino but only using it as a smart hub for zwave devices..
7/30/2017 10:13:06 PM EDT
[#2]
https://www.allaboutcircuits.com/projects/servo-motor-control-with-an-arduino/

There is some sample code there.  Instead of just looping through angles you can have the button press set the value for angle to say 45 when pressed and 135 when not pressed.  Then it will move back and forth when pressed.
7/30/2017 10:19:22 PM EDT
[#3]
While it will get more air play here in GD, you might try over in the Ham radio forum. There are some sharp guys there.
7/31/2017 12:00:56 AM EDT
[#4]
What is your range of input values? [Are you getting your input values from an analogRead command or from something else?] - OK, I see that you say that you're getting your value from a 'digital input', but that is not descriptive enough - can you provide more information? A single digital input? Several in parallel? Something else?

Do you want to map those values into the range of 0 to 180 degrees to pass to servo.write()?

Or is there a more restrictive mapping range that you want to accomplish, or do you want to invert the mapping (high input gives low output value and vice-versa)?  

I can try working up an example on my Arduino if you can provide that info.
Close Join Our Mail List to Stay Up To Date! Win a FREE Membership!

Sign up for the ARFCOM weekly newsletter and be entered to win a free ARFCOM membership. One new winner* is announced every week!

You will receive an email every Friday morning featuring the latest chatter from the hottest topics, breaking news surrounding legislation, as well as exclusive deals only available to ARFCOM email subscribers.


By signing up you agree to our User Agreement. *Must have a registered ARFCOM account to win.