Custom Step

In the previous projects, we used a lot of actions that we wrote, so how are these actions composed and done? Generally speaking, an action is composed of one or more steps.

In this project, we will learn how to customize PiSloth’s step.

All we have to do is to use the buttons in the remote control page to make PiSloth complete the step shown in the figure below, and then get the angles of the 4 Servos at that time.

../_images/diy_pic.jpg

Note

You can download and print the PDF Cartoon Mask for your PiSloth.

Step 1: Drag out 9 buttons in the Remote Control to control the rotation angles of the 4 Servos on the PiSloth.

../_images/DIYII1.png

Step 2: Create 4 variables to store the angles of the 4 Servos.

../_images/DIYII2.png

Then initialize the angle to 0.

../_images/DIYII3.png

Step 3: Reads the values of the different buttons that are used to control the angles of the Servos.

  • button AB control the left-leg.

  • button CD control the left-foot.

  • button EF control the right-leg.

  • button GH control the right-foot.

  • Press button I and the angles of the 4 Servos will be printed in the Debug Monitor.

../_images/DIYII4.png

Step 4: At the end of the Forever block, fill in the angle values read into the 4 servos and use the do action block to make PiSloth do this step.

../_images/DIYII7.png

Step 5: Once the code is complete, click the download icon in the bottom right corner to download and run the code. Now we can click button CD and button GH (according to the actual code) to make PiSloth pose like this, you can also make it do other steps.

../_images/diy_pic.jpg

Step 6: Click on the Debug Monitor icon in the bottom left corner, and you will see the angle of the 4 servos in the Debug Monitor at that moment when you press button I.

Note

Some times more than 2 sets of data may appear because if you click button I for a little longer, EzBlock will think button I was clicked 2 times. You can clear the data and click button I again.

../_images/DIYII5.png

The complete code is as follows:

../_images/DIYII.png