You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/hardware/08.edu/solution-and-kits/alvik/tutorials/setting-alvik-arduino-ide/setting-alvik-arduino-ide.md
+99-13
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ The Arduino® Alvik robot was designed to be compatible with both C++ and MicroP
34
34
35
35
### Firmware Preparation
36
36
37
-
#### Preparing Alvik for Arduino IDE
37
+
#### Preparing Alvik For Arduino IDE
38
38
39
39
1. Connect pin **B1** to **GND** on the Alvik board.
40
40

@@ -43,35 +43,55 @@ The Arduino® Alvik robot was designed to be compatible with both C++ and MicroP
6. Select **Upload Using Programmer** from the **Sketch** menu.
45
45
. You can nowpPress the **Reset** button on the board to make sure it is ready for uploading.
46
-
1. Open the **Bridge** example in the Arduino IDE by going to **File > Examples > 01.Basics > Blink**.
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**.
50
-

51
-
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**.
1. Now we can finaly test it. Open the **Drive** example in the Arduino IDE by going to **File > Examples > Arduino_Alvik > drive**.
47
+

53
48
54
-
55
-
1. After the firmware is programmed your board should now be ready!
49
+
The Alvik should now start their motor. If no movement occurs make sure that:
50
+
- Your board is **ON**
51
+
- Firmware is updated (more information available in the [User Manual](https://docs.arduino.cc/tutorials/alvik/user-manual/)).
56
52
57
53
58
54
59
55
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/).
60
56
61
57
## Programming Alvik
62
58
63
-
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:
59
+
Now that your Alvik is correctly setup lets go over some simple sketch uploads. If this is your first time with the Arduino IDE there is information available on how to [upload sketches](https://support.arduino.cc/hc/en-us/articles/4733418441116-Upload-a-sketch-in-Arduino-IDE).
60
+
61
+
### Libraries
62
+
63
+
There are two libraries available in the library manager for use with Alvik:
64
+
65
+
-**Arduino_Alvik**: This is the primary library we will use in our sketches, and it contains high-level commands for controlling the "brain" of the Alvik, which is the ESP board. You can find more information and download it from [here](https://www.arduino.cc/reference/en/libraries/arduino_alvik/).
66
+
67
+
-**Arduino_AlvikCarrier**: This library is designed for the STM board on the device and is useful in situations where more fine control is required over commands. It allows for more complex development, especially when deeper integration with the hardware is needed. More information and the download link can be found [here](https://www.arduino.cc/reference/en/libraries/arduino_alvikcarrier/).
68
+
69
+
### Print Firmware Version
70
+
71
+
A simple but useful program if you are new to the Alvik is to understand how to get information from the onboard STM board. In this case, we are creating a simple sketch that prints the firmware version using the `get_version()` function.
64
72
65
73
```c++
66
74
#include"Arduino_Alvik.h"
75
+
```
67
76
77
+
Including the `Arduino_Alvik` library is essensial. The library contains all the needed predefined functions and classes that simplify the process of controlling the robot's hardware, such as motors and sensors. Without this include statement, the compiler wouldn't recognize the `Arduino_Alvik` class or its associated methods.
78
+
79
+
```c++
68
80
Arduino_Alvik alvik;
81
+
```
82
+
83
+
When using the Alvik livrary we declare an object of the `Arduino_Alvik` class named `alvik` in this case. All interactions with the robot will go through this `alvik` object. As with our ```alvik.drive()``` command.
69
84
85
+
```c++
70
86
voidsetup() {
71
87
alvik.begin();
72
88
Serial.begin(115200);
73
89
}
90
+
```
91
+
92
+
In the `setup()` function, the `alvik.begin()` method initializes the Alvik robot. This will be a necessity on all sketches for the Alvik.
74
93
94
+
```c++
75
95
voidloop() {
76
96
77
97
uint8_t u,m,l;
@@ -86,9 +106,75 @@ void loop() {
86
106
}
87
107
```
88
108
89
-
After upload the Alvik should rotate the wheels and print the version once per second.
109
+
This code continuously retrieves and prints the firmware version thanks to the ```get_version()``` every second while making the Alvik robot's wheels rotate back and forth using the ```drive()``` command.
110
+
111
+
112
+
**Complete code:**
113
+
114
+
```c++
115
+
#include"Arduino_Alvik.h"
116
+
117
+
Arduino_Alvik alvik;
118
+
119
+
voidsetup() {
120
+
alvik.begin();
121
+
Serial.begin(115200);
122
+
}
123
+
124
+
voidloop() {
125
+
126
+
uint8_t u,m,l;
127
+
128
+
alvik.get_version(u,m,l); // Gets the firmware version
129
+
Serial.printf("%d.%d.%d\n", u, m, l);
130
+
alvik.drive(10, 45);
131
+
delay(1000); // Waits a second
132
+
alvik.drive(10, -45);
133
+
delay(1000); // Waits a second
134
+
135
+
}
136
+
```
137
+
138
+
### Obstacle Avoider Example In C++
139
+
140
+
A more complex example can be found in the [getting started](https://docs.arduino.cc/tutorials/alvik/getting-started/) guide for the Alvik.
141
+
Due to the functions having same structure and names on both MicroPython and C++ we can easily port the ```obstacle-avoider``` to C++.
142
+
143
+
Keeping in mind the initialization of the Alvik from the previous example we can build the example on the Arduino IDE:
You can now explore the other included examples that cover more of the Alvik's components.
177
+
You can now explore the other included examples that cover more of the Alvik's components and more functions listed on our [API reference](https://docs.arduino.cc/tutorials/alvik/api-overview/).
0 commit comments