|
| 1 | +--- |
| 2 | +title: "Start With Alvik And Block-Based Language" |
| 3 | +difficulty: beginner |
| 4 | +description: "Take your first steps with Arduino® Alvik and mBlock." |
| 5 | +tags: |
| 6 | + - Robot, Block-based, Education |
| 7 | +author: "Gaia Castronovo" |
| 8 | +--- |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | +Welcome to your first steps with Alvik, your companion for exploring robotics and programming. In this guide, we'll walk you through setting up your Alvik and starting your journey with block based language. |
| 13 | + |
| 14 | +## What’s Included in the Box |
| 15 | + |
| 16 | +When unboxing Alvik, you should find the following items: |
| 17 | + |
| 18 | +- Alvik robot |
| 19 | +- USB-C® cable (located under the cardboard tray) |
| 20 | + |
| 21 | +## Update Firmware with Alvik Updater |
| 22 | + |
| 23 | +Updating the firmware on your Alvik ensures it has the latest features, bug fixes, and performance improvements. Regular updates help maintain compatibility with the mBlock software and ensure optimal performance of your robot. |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +1. Visit https://alvikupdate.arduino.cc. |
| 28 | +2. Connect Alvik to your computer. |
| 29 | +3. Turn ON your Alvik. |
| 30 | +4. Click the "Connect" button. |
| 31 | +5. **A pop-up window will appear** prompting you to select the COM port. Choose the correct port and confirm. |
| 32 | +6. Once connected, click the "Update" button and wait for the process to complete. |
| 33 | + |
| 34 | +## Preparing Your Environment |
| 35 | + |
| 36 | +During the installation process, you may **need to install additional drivers**, that require access to the **administrator login password** to your OS. |
| 37 | + |
| 38 | +### Supported Systems |
| 39 | + |
| 40 | +You can use a computer with different operating systems like: |
| 41 | + |
| 42 | +* Windows, |
| 43 | +* MacOS, |
| 44 | +* Chromebook, |
| 45 | +* Linux. |
| 46 | + |
| 47 | +***Alvik is not yet supported by mBlock mobile app for Android or iOS devices.*** |
| 48 | + |
| 49 | +### Online Coding |
| 50 | + |
| 51 | +For a quick start, you can use the *mBlock web version*. Scroll down on the [download page](https://mblock.cc/pages/downloads) to download the correct **mLink driver** for your **operating system**. |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | +After downloading, install the **drivers**. This small software helps your computer communicate with the robot. When prompted, simply click "INSTALL." |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +Once mLink is installed, open it and connect to <a href="https://ide.mblock.cc">**ide.mblock.cc**</a> using a web browser (Google Chrome is recommended). From now on, whenever you want to code Alvik, open the mLink application and go to the webpage mentioned above. |
| 60 | + |
| 61 | +### Offline Coding |
| 62 | + |
| 63 | +Please [download the software](https://mblock.cc/pages/downloads), then double-click the installer file and follow the instructions to complete the installation. |
| 64 | + |
| 65 | +If you're using a *Windows* or *Mac* computer, scroll down the page and click the appropriate button. For *Chromebook* or *Linux* users, the process is slightly different. |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | +### Windows |
| 70 | + |
| 71 | +To install mBlock on Windows: |
| 72 | + |
| 73 | +1. Click the "Download for Windows" button, wait for the download to finish, and find the file in your Downloads folder. |
| 74 | + |
| 75 | +  |
| 76 | + |
| 77 | +2. Double-click the downloaded file and click "YES" when prompted. Follow the on-screen instructions to complete the installation. |
| 78 | + |
| 79 | +3. Install the **drivers**: a window will appear asking you to click "INSTALL." |
| 80 | + |
| 81 | +  |
| 82 | +The driver installation window may occasionally open in the background. If this happens, look for the computer icon in your taskbar and click it to proceed. |
| 83 | + |
| 84 | +If you encounter an installation error, click 'UNINSTALL' and then 'INSTALL' again. Once the drivers are installed, close the driver window manually by clicking the 'X'. Afterward, complete the mBlock installation. |
| 85 | + |
| 86 | +### MacOS |
| 87 | + |
| 88 | +To install mBlock on macOS: |
| 89 | + |
| 90 | +1. Click on the "Download for Mac" button on the [Download page](https://mblock.cc/pages/downloads), wait for the download to finish, and find the file in your Downloads folder. |
| 91 | +2. Double-click the downloaded file to mount the `.dmg` file. Then, drag the Panda icon to the Applications folder. |
| 92 | + |
| 93 | +  |
| 94 | + |
| 95 | +3. Open the Applications folder, locate the mBlock app, and open it. The first time you open the software, right-click (or Control-click) on the app and select "Open" from the dropdown menu. |
| 96 | + |
| 97 | +### Chromebook or Linux |
| 98 | + |
| 99 | +If you're using a **Chromebook** ([read the full guide here](https://support.makeblock.com/hc/en-us/articles/19412317319191-Device-Connection-Guide-for-Chromebook-Latest-Version)) or a **Linux** machine, the installation process is different because there is no installable version of the software available. Instead, you'll use the online version of mBlock, which requires a special driver to connect to the robot. |
| 100 | + |
| 101 | +Here you can find the "mLink - mBlock web version driver" and download the appropriate file for your operating system. |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | +## Connect the Robot to mBlock |
| 106 | + |
| 107 | +To program Alvik, start by opening the mBlock software if you haven’t already. Once the software is open, follow these steps to connect: |
| 108 | + |
| 109 | +**1.** Locate the robot's **on/off switch** and slide it to the **OFF** position. |
| 110 | + |
| 111 | +***To ensure a proper connection and protect the robot's battery, always turn off the robot before connecting it to your computer; it may not appear if left on.*** |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | +**2.** <a href="https://ide.mblock.cc">Open mBlock</a>. In the `Device` section, add Alvik as a programmable board by clicking the `+ Add` button, then selecting Alvik from the robot list. |
| 116 | + |
| 117 | + |
| 118 | + |
| 119 | +**3.** **Connect the programming cable** to your computer and the Arduino Nano ESP32. |
| 120 | + |
| 121 | + |
| 122 | + |
| 123 | +**4.** Locate the robot's **on/off switch** and slide it to the **ON** position. |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | +**5.** Establish the connection to **mBlock** clicking on the **Connect** button. |
| 128 | + |
| 129 | + |
| 130 | + |
| 131 | +**6.** Click the **Connect** button in the pop-up window. |
| 132 | + |
| 133 | +In the connect window, select the **Serial Port**, in Windows you might see something like COM4 (or another number), while on other operating systems, it could be something like `/dev/tty.[yourSerialPortName]`. mBlock typically detects the correct port automatically, but if you encounter any issues, make sure the selected port is the right one. |
| 134 | + |
| 135 | + |
| 136 | + |
| 137 | +**7.** You are **ready** to work! |
| 138 | + |
| 139 | +## Blocks |
| 140 | + |
| 141 | +Explore mBlock to start programming your Alvik. In the center of the interface, you’ll find a list of visual blocks, each representing a command that Alvik can execute. These blocks are grouped **into color-coded categories based on the type of action** they perform. |
| 142 | + |
| 143 | +When you're creating a sequence of commands for Alvik you **always need to start by stating the initial event**: |
| 144 | + |
| 145 | + |
| 146 | + |
| 147 | +* `When Alvik starts` - the code will be executed the moment you turn ON Alvik. |
| 148 | + |
| 149 | +or |
| 150 | + |
| 151 | +* `When button [] is pressed` - the code will be executed the moment you press the designated button. |
| 152 | + |
| 153 | +### Block Parameters |
| 154 | + |
| 155 | +Every parameter inside the **rectangle area**, for example the number `5` or the `cancel ▼` element in the dropdown menu can be edited, to give Alvik a different behavior. |
| 156 | + |
| 157 | + |
| 158 | + |
| 159 | +Some blocks, for example in the`Control` section, have a **hexagonal** tile `⬣` parameter, where you can drag and drop in an entire block, allowing you to nest commands like for `if < > then { }`. |
| 160 | + |
| 161 | + |
| 162 | + |
| 163 | +## Blink Example |
| 164 | + |
| 165 | +Alvik comes with two built-in **RGB LEDs**, located on top of the robot. |
| 166 | + |
| 167 | + |
| 168 | + |
| 169 | +On the top of Alvik you can also find **8 buttons**, that let you operate the robot. |
| 170 | + |
| 171 | + |
| 172 | + |
| 173 | +The goal of **our first program** is to make the LEDs flash when you press a button on Alvik: |
| 174 | + |
| 175 | +1. Navigate to the `Events` folder and drag the command `When button [ok] is pressed` to the coding area on the right. |
| 176 | + |
| 177 | +2. Next, go to the `LEDs` folder and drag `set [left] LED color to [RED] for (1) seconds` into the coding area, connecting it to the previous command. |
| 178 | + |
| 179 | +3. You need to upload the code to the robot. **Remember to turn ON the robot when you are transferring the code.** Click the `Upload Code` button in the left side of the interface, and wait for the file transfer. |
| 180 | + |
| 181 | +Now you’ve created your first program: Alvik will turn on the left LED for one second when the OK `✔` button is pressed. |
| 182 | + |
| 183 | + |
| 184 | + |
| 185 | +### ToF Sensor Example |
| 186 | + |
| 187 | +In this second example Alvik will try to keep a constant distance from an object, moving back and forward accordingly. |
| 188 | + |
| 189 | +<video width="100%" loop autoplay> |
| 190 | +<source src="assets/tof-video.mp4" type="video/mp4" /> |
| 191 | +</video> |
| 192 | + |
| 193 | +Navigate to `Control` commands folder. |
| 194 | + |
| 195 | +Inside a loop block called `forever` , use the command `if < > then { } else { }` |
| 196 | + |
| 197 | +Alvik needs time to read the distance sensor therefore we need to avoid executing the loop block `forever` too fast. To fix this, add a **small delay** (about 0.1 seconds) with the block `wait ( )`. This won’t change much in behavior but will give Alvik **enough time to read the sensor**. |
| 198 | + |
| 199 | +We'll also use two other types of blocks: the `Motor` blocks contain all the actions needed to control Alvik's wheels, while the `Distance Sensors` folder holds the blocks for controlling the Time of Flight sensor. |
| 200 | + |
| 201 | +### Next Steps |
| 202 | + |
| 203 | +* For more in depth block-based guided projects with STEAM topics [visit the course page](https://courses.arduino.cc/block-based-coding-robotics). |
| 204 | +* If you want to learn more about how Alvik is built or which functions you can use to program it, visit the documentation in the [Docs space for Alvik](https://docs.arduino.cc/hardware/alvik/) and follow the respective [Alvik's User Manual](https://docs.arduino.cc/hardware/alvik/user-manual) to know more about how to build incredible projects with your robot! |
| 205 | +* If you want to follow step-by-step guided projects following an educational approach to learn MicroPython and robotics topics with Alvik, follow the [Explore Robotics in MicroPython](https://courses.arduino.cc/explore-robotics-micropython/) course. |
0 commit comments