Leçon 1, Chapitre 1
En cours

Robot intelligent – Code Scratch Part 1

Yann KIDSHAKER 18 mars 2025

Introduction

Welcome agents. Most of the boxes in your list of duties for this mission have been checked. What remains is writing the script for controlling the robot. And that is what we’ll be working with now. We’ll divide the entire script into 3 parts:

  1. The script for receiving the code from the Smartphone
  2. Scripts for moving the robot in different directions
  3. Main script

Let’s begin the first part:

The script for receiving the code from the Smartphone

Follow the steps below to write the script:
  1. Open PictoBlox; if already open and working on a project, save that project. Then, click on New.
  2. Select evive from the board in Menubar.
    Choose board
  3. Now, Go to the evive extension and drag and drop the when evive starts up block in the scripting area.
  4. Drag and drop fill screen with () colour block from the evive Display extension below the when evive starts up block, and select any color of your choice from the color picker menu.
  5. To use Dabble App, we have to enable the Dabble extension. Click on add extension on the bottom left corner and select Dabble App.
    Load Extensions
  6. Next, go to the Control palette and drag and drop the forever block below the when evive starts up block.
  7. Go back to the evive Display extension and drag and drop the set cursor at () () block inside the forever block; set the coordinates as 10,10.
  8. From the Control palette, drag and drop the if-else block below the set cursor at () () block.
  9. Go to the Dabble extension and drag and drop the is () pressed on gamepad? block inside the diamond-shaped space of the if-else block. From the drop-down menu select Up, where Up is the top button in the Gamepad module in Dabble.
  10. Next, drag and drop the write () block from the evive Display extension below the if arm of the if-else block and write UP in the space.
  11. Drag and drop fill screen with () color block from the evive TFT Display extension below the else arm of the if-else block, and select the same color that you did in step 4.

Below is the complete script:

Check Bluetooth

Now, we’ll test the script to make sure it runs smoothly. For that, we must first upload it to evive,  and pair the Bluetooth module with evive.

How to upload a script to evive

Follow the steps below to upload the script:

  1. Connect evive to your laptop/PC, and select the appropriate port.
    Connect
  2. Select the Upload mode from.
    Upload Mode
  3. Click on the upload button above the Arduino code generated.

Upload Robot Code

How to pair the HC-05 Bluetooth Module with your Smartphone

Follow the steps below:

  1. Open Dabble in your phone. Dabble is a project-making mobile application developed by STEMpedia. You can install it on your phone from Google Play.
  2. Once you open the app, in the top-right corner, you will see a connect-disconnect icon (it will be in the disconnected). Click on it.
    Home_disconnected
  3. The app will ask for permission to turn Bluetooth ON. Click on Allow to grant the same.
    Turn ON bluetooth
  4. After selecting Allow, the following dialogue box will appear on the screen. Select skip for now.
  5. Next, select the device you want to pair Dabble with.
    Select device
  6. After you select the device, the connected message will appear in the bottom of the screen.
  7. Once the device is paired with Dabble, the connect-disconnect icon will be connected and Dabble’s icon will appear in the top-left corner.
    Home_Connected

After pairing the module and your Smartphone, open the Gamepad module and touch the buttons; you’ll see the corresponding values on the screen. This means that the devices are properly connected, and you’re good to go.