// Challenge Solution Functions void Position_1() // Starting "Prep" position { // Set the target positions to the starting positions posBase = 125; posShoulder = 55; posElbow = 50; posGripper = 0; // Write the starting position to each servo. servoBase.write(posBase); servoShoulder.write(posShoulder); servoElbow.write(posElbow); servoGripper.write(posGripper); } void Position_2() // "Grab" position { // Set the target positions to the starting positions posBase = 125; posShoulder = 75; posElbow = 40; posGripper = 90; // Write the starting position to each servo. servoBase.write(posBase); servoShoulder.write(posShoulder); servoElbow.write(posElbow); servoGripper.write(posGripper); } void Position_3() // "Lift" position { // Set the target positions to the starting positions posBase = 125; posShoulder =55; posElbow = 90; posGripper = 90; // Write the starting position to each servo. servoBase.write(posBase); servoShoulder.write(posShoulder); servoElbow.write(posElbow); servoGripper.write(posGripper); } void Position_4() // "Move" Position { // Set the target positions to the starting positions posBase = 55; posShoulder =55; posElbow = 90; posGripper = 90; // Write the starting position to each servo. servoBase.write(posBase); servoShoulder.write(posShoulder); servoElbow.write(posElbow); servoGripper.write(posGripper); } void Position_5() // "Place" Position { // Set the target positions to the starting positions posBase = 55; posShoulder = 75; posElbow = 40; posGripper = 60; // Write the starting position to each servo. servoBase.write(posBase); servoShoulder.write(posShoulder); servoElbow.write(posElbow); servoGripper.write(posGripper); } void Position_6() // "Depart" Position { // Set the target positions to the starting positions posBase = 55; posShoulder = 55; posElbow = 50; posGripper = 0; // Write the starting position to each servo. servoBase.write(posBase); servoShoulder.write(posShoulder); servoElbow.write(posElbow); servoGripper.write(posGripper); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter