0

Does anybody know of a sketch that can turn a single servo 180 degrees clockwise/counterclockwise with the x axis of a joystick, light a bar graph LED with the Y axis, and sound a buzzer when the joystick button is depressed.

  • 3
    With such a specific set of requirements, why not write such a sketch yourself? It's the Arduino way. – jose can u c Jan 22 '18 at 13:15
  • We are a bit too new, we have learned each of the parts of the code but we are struggling with the servo control and putting them all together. Check out what we learned about doing lots of commands at once arduino.stackexchange.com/questions/48810/… – Jacob Dickson Jan 22 '18 at 13:20
  • 1
    Assuming you are new on Arduino: try to create a sketch separately for each component (you can download them mostly). Than if you feel each component works, combine them to get the functionality that you want. – Michel Keijzers Jan 22 '18 at 13:21
  • 1
    @CodeGorilla Your answer was not posted before I made this remark (but I guess your remark is sarcastic) ... Good answer btw (I upvote it) :-) – Michel Keijzers Jan 22 '18 at 13:34
  • 1
    Michel - Yes it was sarcastic - you know me too well :). @Jacob - I don't think the down vote was because of your age. Your question looks like posting here is the first thing you tried, it looks like you didn't do any research, because you haven't mentioned any. Also because your requirements are so specific most people who post on here would know that there is no chance of there being a sketch that does all that you need. Your age on here is how long you have been a member and having read your other posts you are a mature 2 YO :) – Code Gorilla Jan 23 '18 at 9:52
3

You have a distinct set of requirements that you could turn into a sketch yourself. I'm guessing you have never written a program before, in which case the problem really is you don't know how to do what you want to.

So, break the problem down into small chunks. The less complex a problem the more likely you are to find a generic solution on the web that you can 'borrow'.

  1. How do you turn a servo?
  2. How do you read the position of a joystick?
  3. How do you light a LED bar graph?
  4. How do you sound a buzzer?

I'm pretty certain that you can find pages that tells you how to do each of those in separate sketches. Once you have each of those working you need to merge the setup functions, making sure they don't over write each other and then tackle the loop functions (which will be more difficult). BUT I know there are posts on here about how to merge two sketches into one.

I'm 99% certain you will not find a sketch that does what you want. I'm 99% certain you will be able to coble together a solution that will do what you want if you break it down.

If you get stuck, post the code you have and explain your problem and people will help.

Good luck.

  • Thanks. We learned how to tackle the loop function bit last week which was cool. Here is the first code we wrote - the one at the bottom is our best one. arduino.stackexchange.com/questions/48810/… – Jacob Dickson Jan 22 '18 at 13:28
  • Added an extra answer to your above post. I think the answer could also be applied to this question too. – Code Gorilla Jan 23 '18 at 9:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.