Automatic Swing with Pinoo

Purpose of the Project: To create an automatic swing system with the joystick module and dc motor using the Pinoo control card.

Duration: 2 lessons

Age Group: 9 years old and above

Pinoo Set: Tam set.


  • Learns to code Pinoo control card
  • Learns to code the joystick module.
  • Dc engine learns to code.
  • Improves the skill of setting up algorithms.
  • Improves coding skill.


Materials to be used: Mblock 3 program, Pinoo Control Card, Joystick Module, Dc motor and wheel reel, Connection Cable


Materials Required for Design: Rectangular cardboard, towel paper or toilet paper roll, colored round cardboard, silicone gun, scissors, utility knife, tight rope or fishing line, swing miniature (6 pieces)
Project Preparation:
  1. We start our project by designing the body of our swing. We cut a small square window at the bottom of our roll for cables.

  1. We fix our body on the rectangular cardboard that we will use as the floor with the help of a silicone gun with the window part at the bottom.

  1. We make six holes on the round cardboard with a utility knife at equal intervals.


 4. We cut six equal lengths of rope or twine. We pass the cut ropes through the holes we made on the cardboard.   



 5. We attach the swing miniatures to the ends of the ropes.     

  1. On the back of the cardboard, we align the motor to the middle and fix it with a silicone gun.
  1. We place the motor on the body in such a way that the cable goes into the body. We take the cable end out of the window we opened on the body.
8. We fix the motor on the body with a silicone gun.
9. Let's make the connections with the Pinoo card. We make the motor connection from the white inputs on the card to the input marked B1 B2 next to it.
 10. We pay attention to the colors on the module for our joystick connection. We make our connection to the red-yellow input (number 9), which has the same colors on the Pinoo card.

On the plane, we fix it with a silicone gun so that the inscriptions on the joystick are to the left (in a horizontal position).

11. Links should be as follows.


 12. We have completed our design and connections, now let's move on to the coding part.



13.  We will use mblock-3 application for the coding part.

 14.  Let's connect our Pinoo control card to the computer with the help of the connection cable and enter the Mblock3 application. Then, let's introduce our Pinoo control card to the computer. To do this, we first click on the serial port option from the Connect tab. Then we select COM3. (The number may differ depending on the computer and the port.)
15. After making the serial port connection, let's select the card we will use from the cards tab. We are working with Arduino Nano model.
16. In order to add the Pinoo extension to our computer, we click on the manage extensions option from the extensions tab. In the window that opens, we type "Pinoo" in the search engine and click download to the result. It has been installed on our computer.





 17.  After selecting our card, we click on the Pinoo option from the Extensions tab. We will write our codes with the Pinoo extension.


 18.  In the coding part, we get the code when the Green Flag is clicked from the Events menu to start the application.
 19. We will manage the movements of the swing according to the values ​​received by the joystick module. Joystick module is a module that can generate values ​​in x and y axes. In this project, we will use only the x-axis (horizontal position) of the module.

We will use variables to learn the values ​​of the module. In the Data & Block tab, we create a variable named x.

20.  We need to specify that the x variable we created is equal to the x coordinate of the joystick module. From the Robots tab, we place the code block related to the joystick in the value section.



 21. In order to repeat the value reading process continuously, we take the code block from the control tab with continuous repetition and insert our codes into it.

In the upper left corner, we can observe the values ​​of x. You can also observe the values ​​by moving the joystick to the right and left.

 22. We will provide the movement of the swing with the values ​​that the joystick takes on the x axis. In order to determine the threshold values ​​of the movements, we need to determine the values ​​that the joystick takes on the far right, stationary and leftmost.

• The values ​​for the far right approach 1023. An average value of 700 was determined.

• Its steady state is approximately 400,

• For the far left, the values ​​approach 0. An average value was determined as 60.

You can update these values ​​according to your own project.

Now, let's create the necessary condition states for all these threshold values. From the control tab, we take the if block and the less than block from the operations tab and create our conditional statement.

23. We want the motor to move forward if the condition is met. For this, we get the Pinoo Bot: Wheel right direction forward Speed ​​0 command from the robots tab. We change the Wheel Right section to the left and the Speed ​​section to 255.
 24. We do the same for the case above 700. We're changing the wheel movement to back here.

Since the values ​​need to be checked continuously, we place the relevant code blocks in the continuous repeat block.

25. When the joystick is stationary, we want the swing to stop, that is, the motor not to run. If no condition is met, we add the Wheel Left Direction Forward, Speed ​​0 command to the upper part of the control blocks so that the motor does not move.
26. After completing our codes, we check the operation of our project by clicking the green flag. When we pull the joystick to the right, our swing should turn to the left, when we pull it to the left, it should turn to the right.
 27. If there is no problem in the operation of our project, we need to load the codes we have written into our card in order to operate it with the power source independent of the computer.

For this, we throw away the "Click on the green flag" code we used at the beginning and get the Pinoo Program code from the Robots tab.

 28.  Right click on the code and click on Upload to Arduino. (We work with Arduino as a board.)



 29.  We are waiting for the codes to be uploaded to the card. After the installation is complete, we close the window and disconnect the Pinoo control board connection cable from the computer.



30. We power our Pinoo control board with the help of a 9v battery and a battery cap. We also turn the on / off button right next to the battery input to the ON position.