How can I wrap a switch around a simple servo sweep code?

Received my starter kit 3 hours ago..

Copied the code for servo sweep and made some minor adjustments. Figured out I had to change board and port from this forum. Worked fine and was reasonably easy to follow (barring the void etc.)

Looked at code for a simple switch.

I assume I need to put the servo code between the start and end of the switch code but can't quite get it right. Im sure you all empathise with my 'beginner frustrations'.

Can someone help me out please… the code would be as enlightening as any explanations.



The way we work round here is that you give it a try, post your attempt and tell us what didn't work. It would probably be a good idea to explain what "wrapping a switch round a servo sweep" means to you because it's not immediately obvious to me what should happen or when.

THEN we can help you get it working.


Read the how to use this forum-please read sticky to see how to properly post code. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

switch (someVariable) {
  case aConstant:
  // some code to be executed when
  // someVariable is equal to aConstant

  case anotherConstant:
  // some other code, to be executed when
  // someVariable is equal to anotherConstant

  // Some code to do if someVariable is not
  // equal to aConstant or anotherConstant.