|
| 1 | +--- |
| 2 | +title: "Getting Started with Alvik" |
| 3 | +difficulty: beginner |
| 4 | +description: "Take your first steps with Arduino® Alvik on Arduino IDE" |
| 5 | +tags: |
| 6 | + - Robot, MicroPython, Education |
| 7 | +author: "Pedro Sousa Lima" |
| 8 | +--- |
| 9 | + |
1 | 10 | # Getting Started with Alvik on Arduino IDE
|
2 | 11 |
|
| 12 | +The Arduino® Alvik robot was designed to be compatible with both C++ and MicroPython. To ensure a smooth experience, functions have the same structure and parameters across all environments. This means the [Alvik's API reference](https://docs.arduino.cc/tutorials/alvik/api-overview/) can be used as a resource regardless of which environment you choose. In this guide, we will prepare the board to be programmed using the Arduino IDE. |
| 13 | + |
3 | 14 | ## Requirements
|
4 | 15 |
|
5 | 16 | ### Software
|
6 | 17 |
|
7 |
| -- **Arduino IDE**: The primary development environment for writing, compiling, and uploading code to Alvik. |
8 |
| -- **Alvik Library for Arduino**: A library that provides easy access to the Alvik robot's functionalities. |
| 18 | +- **Arduino IDE**: A modern desktop-based [Arduino IDE](https://support.arduino.cc/hc/en-us/articles/360019833020-Download-and-install-Arduino-IDE). |
| 19 | +- **Alvik Library for Arduino**: A [library](https://github.com/arduino-libraries/Arduino_Alvik) that provides easy access to the Alvik robot's functionalities. |
9 | 20 | - **USB Drivers**: Ensure you have the correct drivers installed to communicate with Alvik via USB.
|
| 21 | +- **STM32Cube**: You will need this 3rd party programmer tool by ST available [here](https://www.st.com/en/development-tools/stm32cubeprog.html) to program the STM board. |
10 | 22 |
|
11 | 23 | ### Hardware
|
12 | 24 |
|
|
29 | 41 |
|
30 | 42 | 1. Connect pin **B1** to **GND** on the Alvik board.
|
31 | 43 | 
|
32 |
| -2. Connect the Alvik board to your computer using the USB cable. |
33 |
| -3. Open the **Blink** example in the Arduino IDE by going to **File > Examples > 01.Basics > Blink**. |
34 |
| - |
35 |
| -4. Select **esptool** as the programmer from the **Tools > Programmer** menu. |
36 |
| - |
37 |
| -5. Select **Upload Using Programmer** from the **Sketch** menu. |
38 |
| - |
39 |
| -6. Your board should now be restored and ready for programming with the Arduino IDE. |
40 |
| - |
41 |
| -#### Preparing Alvik for MicroPython |
42 |
| - |
43 |
| -1. Install the micropython bootloader on it following [this guide](https://docs.arduino.cc/micropython/basics/board-installation/). |
44 |
| - |
45 |
| -2. Download the Alvik micropyton libraries |
46 |
| -Alvik micropython libraries from the [Alvik repository](https://github.com/arduino/arduino-alvik-mpy/tree/main) |
47 |
| -ucPack libraries from the [ucPack repository](https://github.com/arduino/ucPack-mpy/tree/main) |
48 |
| -3. Unzip both of the downloaded libraries in a single "Alvik" folder, open the Arduino Lab for MicroPython, go to the "files" tab and set the path to the unzipped folder on the Arduino Lab for Micropython |
49 |
| -  |
50 |
| -4. Make sure your Alvik is OFF, connect it to your computer and then, turn it ON |
51 |
| -  |
52 |
| -5. Connect your Alvik to the Arduino Labs for micropython and open the "lib" |
53 |
| -  |
54 |
| -6. Select the "Arduino-alvik" and move it inside the "lib" folder in your Alvik. |
55 |
| -  |
56 |
| -7. Go back to the main folder and select the "ucPack-mpy-main" folder and move it next to the arduino_alvik inside the "lib" folder in your Nano ESP32. |
57 |
| -  |
58 |
| -8. Now go back to the main root of the files system on the Nano ESP32. Then in your local folder navigate to the examples folder once there, select the following files and move them to the main folder of the ESP32. |
59 |
| - `demo.py` |
60 |
| - `hand_follower.py` |
61 |
| - `line_follower.py` |
62 |
| - `main.py` |
63 |
| - `touch_move.py` |
64 |
| - |
65 |
| -  |
66 |
| -With this last step, your Nano ESP32 has been set up with the Alvik out of the box experience and is ready to be used. |
| 44 | +3. While both pins are connected plug the Alvik board to your computer using the USB cable. |
| 45 | +5. Select **esptool** as the programmer from the **Tools > Programmer** menu. |
| 46 | + |
| 47 | +6. Select **Upload Using Programmer** from the **Sketch** menu. |
| 48 | +. You can nowpPress the **Reset** button on the board to make sure it is ready for uploading. |
| 49 | +1. Open the **Bridge** example in the Arduino IDE by going to **File > Examples > 01.Basics > Blink**. |
| 50 | + |
| 51 | +1. Open **STM32 Cube Programmer** |
| 52 | +2. Set the connection to **UART** mode, the **Port** to whatever port the board is connected to and **DTR** to HIGH. You can now press **Connect**. |
| 53 | + |
| 54 | +3. Go to **Erasing & Programming** mode and edit the **File path** to the firmware (this will be a .bin file) you are trying to program. You can find the latest release [here](https://github.com/arduino-libraries/Arduino_Alvik/releases/tag/1.0.1). You can now press **Start Programming**. |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | +1. After the firmware is programmed your board should now be ready! |
67 | 59 |
|
68 | 60 |
|
| 61 | + |
| 62 | +You can at any point revert back to the MicroPython programming eviroment by following the content available over at the [MicroPython installation guide](https://docs.arduino.cc/micropython/micropython-course/course/installation/). |
| 63 | + |
69 | 64 | ## Programming Alvik
|
70 | 65 |
|
71 |
| -1. Start with a simple example, like blinking an LED or reading a sensor. |
72 |
| -2. Use the Alvik library functions to interact with the robot's hardware. |
73 |
| -3. Upload your sketch to see it in action. |
74 |
| -4. Explore the included examples in the Alvik library to learn how to control motors, read sensors, and more. |
| 66 | +Let's confirm our firmware is correctly installed. For this we will create a simple sketch that prints the firmware version using the ```get_version()``` function: |
| 67 | + |
| 68 | +```C |
| 69 | +#include "Arduino_Alvik.h" |
| 70 | + |
| 71 | +Arduino_Alvik alvik; |
| 72 | + |
| 73 | +void setup() { |
| 74 | + alvik.begin(); |
| 75 | + Serial.begin(115200); |
| 76 | +} |
| 77 | + |
| 78 | +void loop() { |
| 79 | + |
| 80 | + uint8_t u,m,l; |
| 81 | + |
| 82 | + alvik.get_version(u,m,l); // Gets the firmware version |
| 83 | + Serial.printf("%d.%d.%d\n", u, m, l); |
| 84 | + alvik.drive(10, 45); |
| 85 | + delay(1000); // Waits a second |
| 86 | + alvik.drive(10, -45); |
| 87 | + delay(1000); // Waits a second |
| 88 | + |
| 89 | +} |
| 90 | +``` |
| 91 | + |
| 92 | +After upload the Alvik should rotate the wheels and print the version once per second. |
| 93 | + |
| 94 | +You can now explore the other included examples that cover more of the Alvik's components. |
| 95 | + |
75 | 96 |
|
76 | 97 | ## More Resources (C++)
|
77 | 98 |
|
|
0 commit comments