Day 7: Fun with Quarky

Lesson Description

Learn to control Quarky wirelessly using your keyboard’s arrow keys with simple coding in PictoBlox. Explore basic programming concepts while making Quarky move forward, backward, left, and right, fostering hands-on learning and fun.

Manual control car

A manual control car is a toy vehicle operated by a handheld remote control. Children can steer the car left, right, forward, or backward using buttons or a joystick on the remote. It teaches kids basic hand-eye coordination and introduces them to the concept of remote-controlled devices. This interactive toy provides hours of entertainment and promotes imaginative play.

Control Your Robot Wirelessly

You gave Quarky some cool moves there! But you don’t know how to control it as of yet. In this topic, you’ll learn how to do that. So, let’s get started!

Understanding the Logic

We’re going to control Quarky wirelessly using the arrow keys of the keyboard of your desktop/in the PictoBlox mobile app.

Here’s how:

  1. Using the up arrow key, we will make Quarky move forward.
  2. Using the down arrow key, we will make it move backward.
  3. Using the right arrow key, it will move right.
  4. Using the left arrow key, it will move left.
  5. When none of the arrow keys is pressed, Quarky should stop moving.

Now, let’s put our plan into action!

Let’s Code

  1. First, power up the Quarky and connect it to PictoBlox as shown in the previous topic.
  2. We want to ensure that Quarky moves forward only if the up arrow key is pressed. To check if it is pressed, we’re going to use an if block. Go to the Control palette and drag and drop an if-else block.
    if () then else
  3. Now, go to the Sensing palette and add a key () pressed? block inside the diamond-shaped space of the if block. This block will check if the selected key is pressed. The up arrow key is the default option.
    If the up arrow key is pressed, we want Quarky to move forward. Therefore we will now add a go () at () % speed for the () second block.
  4. Go to the Robot palette and add a go () at () % speed for () second block inside the if block.Now, we need to do the same for the remaining three directions.
  5. Duplicate these blocks by right-clicking the if-else block. Then, in the key () pressed ? block, change the key to down and in the go () at () % speed for () second block, change the direction to backward.
  6. Repeat step two more times for the remaining two directions.
  7. Now put the stop robot block in the last else branch.
  8. Complete the script by adding a forever & when flag clicked blocks at the top.

Now, run the script by clicking the green flag. Have fun playing with Quarky! 🙂

Save the project file as  Wireless Robot.

Table of Contents