PWM Controls-Scratch
Last updated
Was this helpful?
Last updated
Was this helpful?
MantisCode is a browser-based software, that’s based on the Scratch programming language. With MantisCode, you can connect to MantisEDU sensors for data collection and other experiments.
Using MantisCode does not require any software to be installed. The user must simply have access to an internet connected device that runs a modern web browser that supports WebBluetooth. Most modern web browsers support this, with the exception of Safari on MacOS, and Firefox. Google Chrome or Edge are recommended for best results. Mobile browsers are not typically not supported.
From the home page, click on Mantis Sensors to access the sensor of interest.
To get access to the sample lessons and examples for the Rovor, navigate to the Mantis Motor Hat section.
Once you find an example you want to explore, click on the load project button to open the program.
Once the program is loaded, click on the green flag to start.
The Mantis Rover kit allows you to build and program using Scratch, a block-based programming language that is easy to learn and use. With the Mantis Rover, you can explore the world of robotics and learn how to code, while having fun building and controlling your robot.
One of the unique features of the Mantis Rover's is it's Motor Hat Control board. This board is powered by is its Bluetooth connectivity. With Bluetooth, you can wirelessly control your robot and send commands to it using your computer or mobile device. This means that you can program your Mantis Rover to perform a variety of tasks, such as navigating through a maze, or avoiding obstacles.
To connect with the Mantis Rover, you will need to use the connection sprite that is included in the project. After turning on the Motor Hat, press the Green Flag to connect with the Rover. If the Motor Hat was already powered, simply toggle the power button to allow for the device to be reconnected to by your program.
Once connected, you can start coding your robot and see it come to life!
Once you press the green flag, the screen will change to say Scanning of Device.
Once you press the connection button on the Motor Hat, the Device will start to broadcast to allow for the program to connect. Upon a successful connection, you program will update to say “Connected.”
Scratch uses visual blocks or "Scratch blocks" to represent different commands and actions. These blocks can be dragged and dropped onto a workspace to create programs or scripts. Scratch blocks come in different colors and shapes, and each block represents a specific action or command that can be used to create interactive stories, games, and animations.
One of the features of Scratch that makes it easy to use for beginners is the use of loops and conditionals. Loops are blocks that allow you to repeat a certain set of actions multiple times. For example, you can use a "repeat" loop to make a sprite move back and forth across the screen multiple times. The loop will continue to run until a certain condition is met, such as a specific number of times or until a certain amount of time has passed.
Conditionals, on the other hand, are blocks that allow you to create different paths or outcomes based on a certain condition. For example, you can use an "if-else" block to create a program that reacts differently depending on the user's input. If the user clicks on a certain button, the program will do one thing, and if they click on a different button, the program will do something else.
In Scratch, loops and conditionals are represented by specific blocks that you can drag and drop onto your workspace. By combining these blocks with other Scratch blocks, you can create complex programs that can respond to user input, interact with other objects on the screen, and perform a variety of actions.
Events allow for you to trigger an action based on a user input, or program event.
Overall, Scratch blocks are a powerful tool that can be used to create a wide range of projects and programs. By exploring the different types of blocks and experimenting with different combinations, you can gain a better understanding of how programming works and how you can use it to bring your ideas to life.
Loops are available under the controls section of the interface.
The "looks" blocks in Scratch are a set of programming blocks that allow you to change the appearance of sprites (characters or objects) in your Scratch project. The looks blocks can be found in the "Looks" category in the Scratch block palette.
Some common looks blocks include:
1. The "say" block: This block allows you to make a sprite say something. You can enter the text you want the sprite to say directly into the block, or you can use a variable or other block to generate the text dynamically.
2. The "show" and "hide" blocks: These blocks allow you to show or hide a sprite on the screen. For example, you might use the "hide" block to make a sprite disappear when it reaches a certain point on the screen.
3. The "switch costume" block: This block allows you to change the costume (or appearance) of a sprite. You can add multiple costumes to a sprite and use this block to switch between them.
4. The "change size" block: This block allows you to change the size of a sprite. You can make the sprite larger or smaller by entering a value into the block, or you can use a variable or other block to change the size dynamically.
Overall, the looks blocks in Scratch give you a lot of control over the appearance of your sprites, which can help you create engaging and visually appealing projects.
Now that we have a basic understanding of Scratch and the Motor Hat, we can start introducing coding commands to control the board.
The robot comes with a set of programming blocks in Scratch that allow you to control the robot's movements. The main block for controlling the robot's motors is called the "move" block. You can find this block in the "Robots" category in the Scratch block palette.
The "move" block has several options for controlling the robot's movements, including forward, backward, left, and right. You can also control the speed of the robot by adjusting the value in the block. By using the "move" block in combination with the distance readings from the MODI sensor, you can program the robot to move a certain distance or to stop when it reaches a certain point.
In addition to the "move" block, there are also blocks that allow you to control each motor individually. These blocks can be found in the "Mantis" category in the Scratch block palette as well. By using these blocks, you can make the robot turn or move in more complex ways.
Commands can be sent to individual motors. The motor dropdown values can be set to Motor (1) or Motor (2). The speed value can range from -100 to 100. -100 would represent a backwards direction, whereas 100 would represent a forward direction for that motor.
Commands can also be sent to both motors simultaneously using this block. This example would stop the motors because a value of 0 is sent to both motors
This command would move both motors in the same direction at the max speed.
Motor’s 1 and 2 in this example will move in opposite directions.
In this example, keyboard commands are wired up to motion commands. Connect your motor hat and experiment with the commands and values to see how they work.
After connecting your board, use the arrow keys to see how your motors react to the various actions. Change the speed values to see how they impact the motors.
To test these blocks, click this link to load a sample project, .