Aquarium Game with Pinoo
Purpose of the Project: To create a game console for the aquarium game with a water level sensor and joystick using the Pinoo Control Card.
Duration: 2 lessons
Age Group: 7 years old and above
Pinoo Set: Maker set and full set.
- Learns to code Pinoo control board
- Learns water level sensor and joystick coding.
- Algorithm building skill develops.
- Coding skill improves.
Materials to be used: Mblock 3 program, Pinoo control card, water level sensor, joystick, connection cable.
Materials Required for Design: Cardboard, utility knife, goo, box.
The box is covered with cardboard cut to size.
We open a window the size of a water level sensor and joystick anywhere on the game console.
Let's make our connections. We connect the Pinoo water level sensor to the red input number 7.
We connect the Pinoo joystick to the yellow / red input number 9.
We have completed our connections and now let's move on to the coding part. We will use the mblock-3 application for this.
Let's connect our Pinoo control card to the computer with the help of a connection cable and enter the Mblock3 application. Later, let's introduce our Pinoo control card to the computer. For this, we first click on the serial port option from the Connect tab. Then we choose COM4. (The number may differ depending on the computer and port.)
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.
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 write "Pinoo" in the search engine and simply say download to the result. It was installed on our computer.
We come to the extensions tab again and click on the Pinoo option. We will write our codes with the Pinoo extension.
In the coding part, we will first design the game. For this, we delete the panda by clicking the right mouse button on the panda puppet. Then we add the puppet named Shark and Fish by clicking the new puppet button. From the draw new puppet button, we create the blue puppet named Water in the size of our playground.
We click on the Shark puppet we added and get its code when the Green Flag is clicked from the Events menu to start the game.
Since all the code blocks we will write must work continuously until the game is over, we are getting the code block from the control tab continuously.
We will use variables to calculate a score. From the Data & Block tab, we click the Create a variable button and create a variable named point.
We write control codes that will work constantly to be able to move the shark with the Pinoo joystick.
If it is, we use the Pinoo joystick X axis to move it right-left. We choose the pin number as 9. If the X axis is equal to 0, we use the -10 steps to go left, and if the X axis is equal to 1023, we use the 10 step go code to go to the right direction.
If it is, we use the Pinoo joystick Y axis to move up and down with it. We choose the pin number as 9. If the Y axis is equal to 0, we use 10 steps to go up, and if the Y axis is equal to 1023, we use the -10 step go code to go down.
As the shark moves, the points it will gain from the fish it will collect are equal to 100 points, the Dance Space sound is played and the game is terminated.
We click on the fish dummy. When the game starts, we ensure that the score variable is 0. We use the "climb up and see" code to make the fish stand on the water puppet. Throughout the game, the control code is written whether the shark touches the fish puppet. If it is, the fish puppet will be hidden and the score variable is increased by 10 points. If the fish puppet does not touch the water puppet, we will use the hidden code because the fish cannot survive.
The water puppet is selected. We adjust the x and y coordinates where the water puppet covers the entire screen. Control commands that will run continuously throughout the game will be written. The water level sensor must be touched with water so that the water puppet does not move down the screen. When the water level drops below 150, the Y position of the water puppet on the screen will decrease by -5. When the Y position goes down to -400, the Suspense sound will play and the game will be terminated.
After completing our codes, we check the operation of our game by clicking the green flag.
- The shark puppet must be moving with the joystick,
- When we touch the water level sensor with water, the water on the screen should not decrease.
- When the shark touches the fish puppet, the fish puppet needs to be hidden.
- When the water level is over, the game should be over.