Playing Run Run with Pinoo
Purpose of the Project: To move our car to the right and left by escaping the oncoming vehicles thanks to the Pinoo control card and 2 ultrasonic distance sensors.
Duration: 2 lessons
Age Group: 11 years and over
Pinoo Set: Basic, Invention, Maker, Full Set.
• Learns to code Pinoo control card.
• Learns to use ultrasonic distance sensor.
• Improves the skill of setting up algorithms.
• Improves coding skill.
Materials to be used: Mblock 3 program, Pinoo control card, 2 ultrasonic distance sensors, connection cables.
Materials Required for Design: Black cardboard, scissors, wooden planks, silicone gun and silicone.
1. For our project, we first buy our wooden plates.
We write the words left and right on our wooden planks with any pencil.
We fix our wooden plates to our black cardboard with the help of a silicone gun.
Then we fix our ultrasonic distance sensors on our wooden planks and finish our design part in the physical environment.
2.Adding Pinoo extension:
In the window that opens, we type "Pinoo" into the search engine and simply say download to the result.
It was installed on our computer.
3.Connecting the Pinoo sensor board to the computer:
We click on the "Serial Port" section from the window that opens and select the "COM6" option from the page that opens.
NOTE: Since the port entries of each computer are different, the numbers next to the COM text may change.
We click on "Firmware Update" from the window that opens.
4. Coding part:
We open the Mblock 3 program and delete our panda puppet.
We click on the draw new decor option to draw the path in our own game.
In the window we see, we paint our decor to the road color with the fill with color tool.
Then, after selecting the rectangle tool, we select the filling and white color of the rectangle we will draw. In this way, we draw our 3-lane road.
Again, we give a green image to the edges of our road with our fill with color tool.
Then we add the puppets that we download to our computer with the option to select the puppets from the computer.
We added our puppets and now we will paint our oncoming vehicle in different colors and make it look like different vehicles are coming.
For this, we choose our vehicle and come to the disguises section. From here, we click the right button of our mouse and say copy.
We paint the other costume of our puppet, which we copied, in a different color with our fill with color tool. Here we can add more cars and create cars in different colors.
We select our vehicle to come from and start coding from the arrays section. Since our game will start when the green flag is clicked, we get our green flag code, and we add the view code because we want our car to appear at the start of the game, and because we want it to be at a certain point, we add our go to point code after placing our vehicle where we want it. Since it will constantly come down from the top of the coordinate plane, we make it come down by increasing the value by -10 on the y axis.
Then, when our same vehicle comes to the bottom of our stage, we want it to go up the stage again, so if the y position of our vehicle is less than -170, we add the go up condition block again.
After our vehicle comes down, we added the necessary codes to hide it for 5 seconds so that it does not come at the same time with the vehicles coming from other lanes.
Later, our vehicle will earn points if it passes every oncoming vehicle without crashing. To keep these scores, we define a variable named points.
The game is over when our vehicle hits oncoming vehicles, we add a different decor from the library to add a different decor to get the feedback.
We create the text "GAME OVER" and "Score" on the decor we added with the help of the text tool. We position our variable that will show the point value in the right place on the stage. We will set the point value to be hidden while playing the game.
In order to ensure that our vehicle we come across is randomly disguised, we take a random number from the operations section and disguise it from the view section and place it in our random number capture code. Since we have 2 guards, we make a number between 1 and 2 and add a 1 second wait code so that our oncoming vehicle does not come as soon as the game starts.
Then we get a different green flag code so that our codes do not get mixed up. At the beginning of the game, we set our score variable to 0. Then we use the if block to check whether it is worth our vehicle or not. Is it worth it? We get our code from the detect tab.
If our vehicles come in contact with each other, we want them to be passed on to the other decor we have added and prepared. We add the switch code and hide code to the decor from the view menu. Since the game is over, we stop our game with the stop all code.
Then we add the show code of our normally hidden score variable from the data & block section. We do not forget to add our code to increase the score variable by 1, as it appears in a red frame in our code block on the left. In this way, when our oncoming vehicle does not hit the vehicle we control, our score will increase by 1.
Now we start coding our vehicle that we will control. We do not forget to select the required puppet before coding for this. Again, we are adding the green flag code and our see code. We add our score variable under our hide code.
After placing our puppet, we add the starting code at a certain point in our vehicle from the movement tab. When it goes left and right, we add our filter code into our code with continuous repetition to come back to the middle lane.
Then, if the value of our 1st distance sensor is less than 10 cm, we add our glide code on the left side in 0.5 seconds from the motion tab after placing our vehicle on the left lane.
Likewise, if the value of our 2nd distance sensor is less than 10 cm, we add our glide code from the motion tab after placing our puppet on the lane on the right.
Now that we have completed our codes to a great extent, we are now creating 2 more copies of our puppet to download.
After copying our puppets, we place our tools correctly. In our copy puppets, we change some of the codes we need to change. We change our go to point code because they will be in different positions and we change the seconds at different values so that our vehicles do not come at the same time. We apply these changes to our puppet that will come from 3 downloads. We also add our code to switch to road decoration under any of our green flag codes.
When our game is over, we add the news code from the ‘’events’’ tab to hide our vehicle, which we control, and create a news called finished. We need some time for the news to reach the other puppet. That's why we add a 0.5 second hold code where necessary.
We come to the codes of our vehicle that we have checked again and when the "finished" news comes, we add our code from the "events" tab and add our "hidden" code from the "appearance" tab. In this way, we complete our coding process.
5. Working Status of the Project:
We attach our distance sensor on the left to the 5th door and the distance sensor on the right to the 6th door and start our fun game by pressing the green flag. We are trying to prevent our vehicle from hitting oncoming vehicles by bringing our hands in front of our distance sensor, whichever direction we want our vehicle to go.