diff --git a/content/micropython/03.micropython/modulinos/01.installation/assets/MicroPythonPackageInstallationDone.png b/content/micropython/03.micropython/modulinos/01.installation/assets/MicroPythonPackageInstallationDone.png new file mode 100644 index 0000000000..ae8645faae Binary files /dev/null and b/content/micropython/03.micropython/modulinos/01.installation/assets/MicroPythonPackageInstallationDone.png differ diff --git a/content/micropython/03.micropython/modulinos/01.installation/assets/microPythonInstaller.png b/content/micropython/03.micropython/modulinos/01.installation/assets/microPythonInstaller.png new file mode 100644 index 0000000000..35bc310d6c Binary files /dev/null and b/content/micropython/03.micropython/modulinos/01.installation/assets/microPythonInstaller.png differ diff --git a/content/micropython/03.micropython/modulinos/01.installation/assets/microPythonLabs.png b/content/micropython/03.micropython/modulinos/01.installation/assets/microPythonLabs.png new file mode 100644 index 0000000000..05234fc82d Binary files /dev/null and b/content/micropython/03.micropython/modulinos/01.installation/assets/microPythonLabs.png differ diff --git a/content/micropython/03.micropython/modulinos/01.installation/assets/microPythonLabsFiles.png b/content/micropython/03.micropython/modulinos/01.installation/assets/microPythonLabsFiles.png new file mode 100644 index 0000000000..da29c64214 Binary files /dev/null and b/content/micropython/03.micropython/modulinos/01.installation/assets/microPythonLabsFiles.png differ diff --git a/content/micropython/03.micropython/modulinos/01.installation/assets/microPythonLabsSelectPort.png b/content/micropython/03.micropython/modulinos/01.installation/assets/microPythonLabsSelectPort.png new file mode 100644 index 0000000000..0837793cce Binary files /dev/null and b/content/micropython/03.micropython/modulinos/01.installation/assets/microPythonLabsSelectPort.png differ diff --git a/content/micropython/03.micropython/modulinos/01.installation/assets/package-installed.png b/content/micropython/03.micropython/modulinos/01.installation/assets/package-installed.png new file mode 100644 index 0000000000..a24a08957c Binary files /dev/null and b/content/micropython/03.micropython/modulinos/01.installation/assets/package-installed.png differ diff --git a/content/micropython/03.micropython/modulinos/01.installation/installation.md b/content/micropython/03.micropython/modulinos/01.installation/installation.md new file mode 100644 index 0000000000..1cb5d092f3 --- /dev/null +++ b/content/micropython/03.micropython/modulinos/01.installation/installation.md @@ -0,0 +1,117 @@ +--- +title: 'Modulino Installation' +description: 'Get started with using the Modulinos' +author: 'Hannes Siebeneicher, Sebastian Romero' +tags: [MicroPython, Package Installation] +--- + +In this tutorial, we will go through the installation process required for programming the Arduino Modulinos with MicroPython. + +## Goals + +The goals of this tutorial are: + +- Learn how to install a MicroPython package on an Arduino board (the Modulino package). + +## Hardware & Software Needed + +We will need a MicroPython compatible board that works with the Modulinos: +- [Arduino Nano ESP32](https://store.arduino.cc/products/nano-esp32?queryID=undefined) +- [Arduino Nano RP2040 Connect](https://store.arduino.cc/en-se/products/arduino-nano-rp2040-connect) + +We will also need the following software: +- [MicroPython Labs](https://lab-micropython.arduino.cc/) +- [MicroPython Installer](https://labs.arduino.cc/en/labs/micropython-installer) +- [Modulino MicroPython package](https://github.com/arduino/arduino-modulino-mpy) + +## Install MicroPython + +To follow this tutorial, we will need to install MicroPython on our Arduino board. The easiest way is to install it using the [MicroPython Installer](https://labs.arduino.cc/en/labs/micropython-installer). + +- Open the installer. +- Connect the board to the computer. +- If it does not appear press the refresh button. +- Press "Install MicroPython". +- Wait for the installation to finish. + +![MicroPython Installer](./assets/microPythonInstaller.png) + +***More details on installing MicroPython on our board are available in the [MicroPython Installation guide]().*** + +## Install Modulino Package + +To program Modulinos using MicroPython we must first install the Modulino package. It's where all the code, necessary to interact with the Modulinos is being stored. + +There are two ways of installing a package: +- Through a terminal +- + +### Terminal Installation + +The easiest way of installing it is using `mpremote`. Currently, we will need a version of Python installed on our computer. + +1. Open a terminal, and write the following line: + ```bash + pip install mpremote + ``` + This will install `mpremote`, which makes it possible to install packages on our board via our computer. +2. With `mpremote` installed, we need to run the following command to identify our board's serial port: + ```bash + mpremote connect list + ``` + + Which will give us something like this: + + ```bash + /dev/cu.usbmodem101 ecda3b60a4dccb3f 2341:056b Arduino Nano ESP32 + ``` + - The port here is `/dev/cu.usbmodem101`. Copy this. + +3. Now, run the following the command. Make sure to replace `` with the port of our device obtained in the previous step. + ```bash + mpremote connect mip install github:arduino/arduino-modulino-mpy + ``` + + Upon completion, we should see something like this in the terminal, to verify the success of the installation: + ![Successful installation.](assets/package-installed.png) + +4. Great job. We have now installed the Modulino package on our board! + +**Troubleshooting:** +- Make sure your board is connected to your computer. +- Make sure it is **not** connected in the Arduino Lab for MicroPython, as this might disturb the connection. +- If you are unable to run `mpremote` in the terminal, this means it is not installed. +- If you are unable to run `python` in the terminal, make sure you have installed Python (you can download and install it [here](https://www.python.org/downloads/)) +- If you have installed Python and it is still not working, try running `python3` and `pip3` instead. +- If you installed Python while having the terminal open, try closing the terminal and re-opening it. +- If you run `mpremote` and there's no board appearing in the list, try re-installing the firmware on your board as it might have failed during installation. + +## MicroPython Labs + +We can now verify that everything was installed correctly. Go to [MicroPython Labs](https://lab-micropython.arduino.cc/) and click on the connect icon in the top left corner. + +![MicroPython Labs](./assets/microPythonLabs.png) + +Select the board and press select "connect". We should now be connected to our Arduino board. + +***If we experience any issues, try disconnecting and connecting the board again and reinstall MicroPython using the [MicroPython Installer](https://labs.arduino.cc/en/labs/micropython-installer).*** + +To verify that the Modulino package has been installed correctly, click on the file icon in the top bar of the Labs editor. + +We should see a folder called `lib` and a file called `boot.py`. Go ahead and press on the `lib` folder and we should see several files and a folder called `modulino`. + +![MicroPython Lab Files](./assets/microPythonLabsFiles.png) + +If we see this, it means the package has been installed successfully. + +## Next Steps + +Now that we have successfully installed everything it's time to program our first Modulino. Below are links to the documentation for all Modulinos. They are also accessible in the side menu at [Arduino Docs - MicroPython](https://docs.arduino.cc/micropython/), under "Modulinos". + +- [Modulino Distance](/micropython/modulinos/modulino-distance) +- [Modulino Pixels](/micropython/modulinos/modulino-pixels) +- [Modulino Buzzer](/micropython/modulinos/modulino-buzzer) +- [Modulino Buttons](/micropython/modulinos/modulino-buttons) +- [Modulino Knob](/micropython/modulinos/modulino-knob) +- [Modulino Movement](/micropython/modulinos/modulino-movement) +- [Modulino Thermo](/micropython/modulinos/modulino-thermo) \ No newline at end of file diff --git a/content/micropython/03.micropython/modulinos/02.modulino-distance/modulino-distance.md b/content/micropython/03.micropython/modulinos/02.modulino-distance/modulino-distance.md new file mode 100644 index 0000000000..ef139f29bb --- /dev/null +++ b/content/micropython/03.micropython/modulinos/02.modulino-distance/modulino-distance.md @@ -0,0 +1,50 @@ +--- +title: 'Modulino Distance' +description: 'Get started with the Modulino Distance using MicroPython' +author: 'Hannes Siebeneicher, Sebastian Romero' +tags: [MicroPython, Time of Flight, Sensors] +--- + +In this tutorial, we will get started with the Modulino Distance, which can measure the distance to an object. + +***Note that the installation of the Modulino package is not covered in this tutorial. For details on how to install this, visit the [MicroPython - Modulino Package Installation tutorial](/micropython/modulinos/installation).*** + +## Goals + +The goals of this tutorial are: + +- learn how to connect a Modulino to an Arduino using MicroPython +- learn how to program the Modulino Distance. + +## Hardware & Software Needed + +For this tutorial, we will need the following hardware: +- [Modulino Distance](https://store.arduino.cc/products/plug-and-make-kit) +- [Arduino Nano to QWIIC Connector Carrier]() +- [Arduino Nano ESP32](https://store.arduino.cc/products/nano-esp32?queryID=undefined) or [Arduino Nano RP2040 Connect](https://store.arduino.cc/en-se/products/arduino-nano-rp2040-connect) + +We will also need the following software: +- [MicroPython Labs](https://lab-micropython.arduino.cc/) +- [Modulino MicroPython Package](https://github.com/arduino/arduino-modulino-mpy) + +## Connect the Modulino + +Before we start programming, we will need to connect our Modulino Distance to our Arduino board. For this we can follow the circuit diagram below: + +![Circuit Diagram]() + +## Modulino Distance Code Example + +Copy the code below and run it in Arduino MicroPython labs, while connected to our board. + +```python +from modulino import ModulinoDistance +from time import sleep_ms + +distance = ModulinoDistance() + +while True: + print(f"📏 Distance: {distance.distance} cm") + sleep_ms(50) +``` + diff --git a/content/micropython/03.micropython/modulinos/03.modulino-pixels/modulino-pixels.md b/content/micropython/03.micropython/modulinos/03.modulino-pixels/modulino-pixels.md new file mode 100644 index 0000000000..a109944d60 --- /dev/null +++ b/content/micropython/03.micropython/modulinos/03.modulino-pixels/modulino-pixels.md @@ -0,0 +1,92 @@ +--- +title: 'Modulino Pixels' +description: 'Get started with the Modulino Pixels using MicroPython' +author: 'Hannes Siebeneicher, Sebastian Romero' +tags: [MicroPython, RGB, Pixel Strip] +--- + +In this tutorial, we will get started with the Modulino Pixels and control its RGB LEDs. + +***Note that the installation of the Modulino package is not covered in this tutorial. For details on how to install this, visit the [MicroPython - Modulino Package Installation tutorial](/micropython/modulinos/installation).*** + +## Goals + +The goals of this tutorial are: + +- learn how to connect a Modulino to an Arduino board. +- learn how to program the Modulino Pixels. + +## Hardware & Software Needed + +For this tutorial, we will need the following hardware: +- [Modulino Pixels](https://store.arduino.cc/products/plug-and-make-kit) +- [Arduino Nano to QWIIC Connector Carrier]() +- [Arduino Nano ESP32](https://store.arduino.cc/products/nano-esp32?queryID=undefined) or [Arduino Nano RP2040 Connect](https://store.arduino.cc/en-se/products/arduino-nano-rp2040-connect) + +We will also need the following software: +- [MicroPython Labs](https://lab-micropython.arduino.cc/) +- [Modulino MicroPython Package](https://github.com/arduino/arduino-modulino-mpy) + +## Connect the Modulino + +Before we start programming, we will need to connect our Modulino Pixels to our Arduino board. For this we can follow the circuit diagram below: + +![Circuit Diagram]() + +## Modulino Pixels Code Example + +Copy the code below and run it in Arduino MicroPython labs, while connected to our board. + +```python +from modulino import ModulinoPixels, ModulinoColor +from time import sleep + +pixels = ModulinoPixels() + +for index in range(0, 8): + color_wheel_colors = [ + (255, 0, 0), + (255, 85, 0), + (255, 255, 0), + (0, 255, 0), + (0, 255, 255), + (0, 0, 255), + (255, 0, 255), + (255, 0, 0) + ] + pixels.set_rgb(index, *color_wheel_colors[index], 100) +pixels.show() +sleep(1) + +pixels.set_all_rgb(255, 0, 0, 100) +pixels.show() +sleep(1) + +pixels.set_all_color(ModulinoColor.GREEN, 100) +pixels.show() +sleep(1) + +pixels.set_all_color(ModulinoColor.BLUE, 100) +pixels.show() +sleep(1) + + +# Night Rider animation + +for j in range(0, 3): + for i in range(0, 8): + pixels.clear_all() + pixels.set_rgb(i, 255, 0, 0, 100) + pixels.show() + sleep(0.05) + + for i in range(7, -1, -1): + pixels.clear_all() + pixels.set_rgb(i, 255, 0, 0, 100) + pixels.show() + sleep(0.05) + +# Turn off all LEDs +pixels.clear_all() +pixels.show() +``` diff --git a/content/micropython/03.micropython/modulinos/04.modulino-buzzer/modulino-buzzer.md b/content/micropython/03.micropython/modulinos/04.modulino-buzzer/modulino-buzzer.md new file mode 100644 index 0000000000..66bac17251 --- /dev/null +++ b/content/micropython/03.micropython/modulinos/04.modulino-buzzer/modulino-buzzer.md @@ -0,0 +1,95 @@ +--- +title: 'Modulino Buzzer' +description: 'Get started with the Modulino Buzzer using MicroPython' +author: 'Hannes Siebeneicher, Sebastian Romero' +tags: [MicroPython, Piezo, Speaker] +--- + +In this tutorial, we will get started with the Modulino Buzzer, a piezo speaker that can output sound. + +***Note that the installation of the Modulino package is not covered in this tutorial. For details on how to install this, visit the [MicroPython - Modulino Package Installation tutorial](/micropython/modulinos/installation).*** + +## Goals + +The goals of this tutorial are: + +- learn how to connect a Modulino to an Arduino board. +- learn how to program the Modulino Buzzer. + +## Hardware & Software Needed + +For this tutorial, we will need the following hardware: +- [Modulino Buzzer](https://store.arduino.cc/products/plug-and-make-kit) +- [Arduino Nano to QWIIC Connector Carrier]() +- [Arduino Nano ESP32](https://store.arduino.cc/products/nano-esp32?queryID=undefined) or [Arduino Nano RP2040 Connect](https://store.arduino.cc/en-se/products/arduino-nano-rp2040-connect) + +We will also need the following software: +- [MicroPython Labs](https://lab-micropython.arduino.cc/) +- [Modulino MicroPython Package](https://github.com/arduino/arduino-modulino-mpy) + +## Connect the Modulino + +Before we start programming, we will need to connect our Modulino Buzzer to our Arduino board. For this we can follow the circuit diagram below: + +![Circuit Diagram]() + +## Modulino Buzzer Code Example + +Copy the code below and run it in Arduino MicroPython labs, while connected to our board. + +```python +from modulino import ModulinoBuzzer +from time import sleep + +buzzer = ModulinoBuzzer() + +# Super Mario Bros theme intro +melody = [ + (ModulinoBuzzer.NOTES["E5"], 125), + (ModulinoBuzzer.NOTES["REST"], 25), + (ModulinoBuzzer.NOTES["E5"], 125), + (ModulinoBuzzer.NOTES["REST"], 125), + (ModulinoBuzzer.NOTES["E5"], 125), + (ModulinoBuzzer.NOTES["REST"], 125), + (ModulinoBuzzer.NOTES["C5"], 125), + (ModulinoBuzzer.NOTES["E5"], 125), + (ModulinoBuzzer.NOTES["REST"], 125), + (ModulinoBuzzer.NOTES["G5"], 125), + (ModulinoBuzzer.NOTES["REST"], 375), + (ModulinoBuzzer.NOTES["G4"], 250) +] + +for note, duration in melody: + buzzer.tone(note, duration, blocking=True) + +# Wait 2 seconds before playing the next melody +sleep(2) + +# Police siren sound effect +def generate_siren(frequency_start, frequency_end, total_duration, steps, iterations): + siren = [] + mid_point = steps // 2 + duration_rise = total_duration // 2 + duration_fall = total_duration // 2 + + for _ in range(iterations): + for i in range(steps): + if i < mid_point: + # Easing in rising part + step_duration = duration_rise // mid_point + (duration_rise // mid_point * (mid_point - i) // mid_point) + frequency = int(frequency_start + (frequency_end - frequency_start) * (i / mid_point)) + else: + # Easing in falling part + step_duration = duration_fall // mid_point + (duration_fall // mid_point * (i - mid_point) // mid_point) + frequency = int(frequency_end - (frequency_end - frequency_start) * ((i - mid_point) / mid_point)) + + siren.append((frequency, step_duration)) + + return siren + +# 4 seconds up and down siren, with 200 steps and 2 iterations +siren_melody = generate_siren(440, 880, 4000, 200, 2) + +for note, duration in siren_melody: + buzzer.tone(note, duration, blocking=True) +``` \ No newline at end of file diff --git a/content/micropython/03.micropython/modulinos/05.modulino-buttons/modulino-buttons.md b/content/micropython/03.micropython/modulinos/05.modulino-buttons/modulino-buttons.md new file mode 100644 index 0000000000..9d8f9fb48d --- /dev/null +++ b/content/micropython/03.micropython/modulinos/05.modulino-buttons/modulino-buttons.md @@ -0,0 +1,67 @@ +--- +title: 'Modulino Buttons' +description: 'Get started with the Modulino Buttons using MicroPython' +author: 'Hannes Siebeneicher, Sebastian Romero' +tags: [MicroPython, Pushbuttons, Digital Input] +--- + +In this tutorial, we will get started with the Modulino Buttons, a three-button Modulino. + +***Note that the installation of the Modulino package is not covered in this tutorial. For details on how to install this, visit the [MicroPython - Modulino Package Installation tutorial](/micropython/modulinos/installation).*** + +## Goals + +The goals of this tutorial are: + +- learn how to connect a Modulino to an Arduino board. +- learn how to program the Modulino Buttons. + +## Hardware & Software Needed + +For this tutorial, we will need the following hardware: +- [Modulino Buttons](https://store.arduino.cc/products/plug-and-make-kit) +- [Arduino Nano to QWIIC Connector Carrier]() +- [Arduino Nano ESP32](https://store.arduino.cc/products/nano-esp32?queryID=undefined) or [Arduino Nano RP2040 Connect](https://store.arduino.cc/en-se/products/arduino-nano-rp2040-connect) + +We will also need the following software: +- [MicroPython Labs](https://lab-micropython.arduino.cc/) +- [Modulino MicroPython Package](https://github.com/arduino/arduino-modulino-mpy) + + +## Connect the Modulino + +Before we start programming, we will need to connect our Modulino Buttons to our Arduino board. For this we can follow the circuit diagram below: + +![Circuit Diagram]() + +## Modulino Buttons Code Example + +Copy the code below and run it in Arduino MicroPython labs, while connected to our board. + +```python +from modulino import ModulinoButtons + +buttons = ModulinoButtons() + +buttons.on_button_a_press = lambda : print("Button A pressed") +buttons.on_button_a_long_press = lambda : print("Button A long press") +buttons.on_button_a_release = lambda : print("Button A released") + +buttons.on_button_b_press = lambda : print("Button B pressed") +buttons.on_button_b_long_press = lambda : print("Button B long press") +buttons.on_button_b_release = lambda : print("Button B released") + +buttons.on_button_c_press = lambda : print("Button C pressed") +buttons.on_button_c_long_press = lambda : print("Button C long press") +buttons.on_button_c_release = lambda : print("Button C released") + + +while True: + buttons_state_changed = buttons.update() + + if(buttons_state_changed): + led_a_status = buttons.is_pressed(0) # Turn LED A on if button A is pressed + led_b_status = buttons.is_pressed(1) # Turn LED B on if button B is pressed + led_c_status = buttons.is_pressed(2) # Turn LED C on if button C is pressed + buttons.set_led_status(led_a_status, led_b_status, led_c_status) +```` diff --git a/content/micropython/03.micropython/modulinos/06.modulino-knob/modulino-knob.md b/content/micropython/03.micropython/modulinos/06.modulino-knob/modulino-knob.md new file mode 100644 index 0000000000..1655acacad --- /dev/null +++ b/content/micropython/03.micropython/modulinos/06.modulino-knob/modulino-knob.md @@ -0,0 +1,58 @@ +--- +title: 'Modulino Knob' +description: 'Get started with the Modulino Knob using MicroPython' +author: 'Hannes Siebeneicher, Sebastian Romero' +tags: [MicroPython, Rotary Encoder] +--- + +In this tutorial, we will get started with the Modulino Knob, a rotating knob with a button. + +***Note that the installation of the Modulino package is not covered in this tutorial. For details on how to install this, visit the [MicroPython - Modulino Package Installation tutorial](/micropython/modulinos/installation).*** + +## Goals + +The goals of this tutorial are: + +- learn how to connect a Modulino to an Arduino board. +- learn how to program the Modulino Knob. + +## Hardware & Software Needed + +For this tutorial, we will need the following hardware: +- [Modulino Knob](https://store.arduino.cc/products/plug-and-make-kit) +- [Arduino Nano to QWIIC Connector Carrier]() +- [Arduino Nano ESP32](https://store.arduino.cc/products/nano-esp32?queryID=undefined) or [Arduino Nano RP2040 Connect](https://store.arduino.cc/en-se/products/arduino-nano-rp2040-connect) + +We will also need the following software: +- [MicroPython Labs](https://lab-micropython.arduino.cc/) +- [Modulino MicroPython Package](https://github.com/arduino/arduino-modulino-mpy) + +## Connect the Modulino + +Before we start programming, we will need to connect our Modulino Knob to our Arduino board. For this we can follow the circuit diagram below: + +![Circuit Diagram]() + +## Modulino Knob Code Example + +Copy the code below and run it in Arduino MicroPython labs, while connected to our board. + +```python +from modulino import ModulinoKnob +from time import sleep + +knob = ModulinoKnob() +knob.value = 5 # (Optional) Set an initial value +knob.range = (-10, 10) # (Optional) Set a value range + +knob.on_press = lambda: print("🔘 Pressed!") +knob.on_release = lambda: (knob.reset(), print("🔘 Released!")) +knob.on_rotate_clockwise = lambda steps, value: print(f"🎛️ Rotated {steps} steps clockwise! Value: {value}") +knob.on_rotate_counter_clockwise = lambda steps, value: print(f"🎛️ Rotated {steps} steps counter clockwise! Value: {value}") + +while True: + if(knob.update()): + print("👀 Knob value or state changed!") + + sleep(0.1) +```` diff --git a/content/micropython/03.micropython/modulinos/07.modulino-thermo/modulino-thermo.md b/content/micropython/03.micropython/modulinos/07.modulino-thermo/modulino-thermo.md new file mode 100644 index 0000000000..1f9f20bc65 --- /dev/null +++ b/content/micropython/03.micropython/modulinos/07.modulino-thermo/modulino-thermo.md @@ -0,0 +1,56 @@ +--- +title: 'Modulino Thermo' +description: 'Get started with the Modulino Thermo using MicroPython' +author: 'Hannes Siebeneicher, Sebastian Romero' +tags: [MicroPython, Environmental Sensor] +--- + +In this tutorial, we will get started with the Modulino Thermo, reading surrounding temperature and humidity. + +***Note that the installation of the Modulino package is not covered in this tutorial. For details on how to install this, visit the [MicroPython - Modulino Package Installation tutorial](/micropython/modulinos/installation).*** + +## Goals + +The goals of this tutorial are: + +- learn how to connect a Modulino to an Arduino board. +- learn how to program the Modulino Thermo. + +## Hardware & Software Needed + +For this tutorial, we will need the following hardware: +- [Modulino Thermo](https://store.arduino.cc/products/plug-and-make-kit) +- [Arduino Nano to QWIIC Connector Carrier]() +- [Arduino Nano ESP32](https://store.arduino.cc/products/nano-esp32?queryID=undefined) or [Arduino Nano RP2040 Connect](https://store.arduino.cc/en-se/products/arduino-nano-rp2040-connect) + +We will also need the following software: +- [MicroPython Labs](https://lab-micropython.arduino.cc/) +- [Modulino MicroPython Package](https://github.com/arduino/arduino-modulino-mpy) + +## Connect the Modulino + +Before we start programming, we will need to connect our Modulino Thermo to our Arduino board. For this we can follow the circuit diagram below: + +![Circuit Diagram]() + +## Modulino Thermo Code Example + +Copy the code below and run it in Arduino MicroPython labs, while connected to our board. + +```python +from modulino import ModulinoThermo +from time import sleep + +thermo_module = ModulinoThermo() + +while True: + temperature = thermo_module.temperature + humidity = thermo_module.relative_humidity + + if temperature != None and humidity != None: + print(f"🌡️ Temperature: {temperature:.1f} °C") + print(f"💧 Humidity: {humidity:.1f} %") + print() + + sleep(2) +```` diff --git a/content/micropython/03.micropython/modulinos/08.modulino-movement/modulino-movement.md b/content/micropython/03.micropython/modulinos/08.modulino-movement/modulino-movement.md new file mode 100644 index 0000000000..4372d5bf44 --- /dev/null +++ b/content/micropython/03.micropython/modulinos/08.modulino-movement/modulino-movement.md @@ -0,0 +1,51 @@ +--- +title: 'Modulino Movement' +description: 'Get started with using the Modulino Movement' +author: 'Hannes Siebeneicher, Sebastian Romero' +tags: [MicroPython, Movement, IMU] +--- + +In this tutorial, we will get started with the Modulino Movement, measuring acceleration and positioning. + +***Note that the installation of the Modulino package is not covered in this tutorial. For details on how to install this, visit the [MicroPython - Modulino Package Installation tutorial](/micropython/modulinos/installation).*** + +## Goals + +The goals of this tutorial are: + +- learn how to connect a Modulino to an Arduino board. +- learn how to program the Modulino Movement. + +## Hardware & Software Needed + +For this tutorial, we will need the following hardware: +- [Modulino Movement](https://store.arduino.cc/products/plug-and-make-kit) +- [Arduino Nano to QWIIC Connector Carrier]() +- [Arduino Nano ESP32](https://store.arduino.cc/products/nano-esp32?queryID=undefined) or [Arduino Nano RP2040 Connect](https://store.arduino.cc/en-se/products/arduino-nano-rp2040-connect) + +We will also need the following software: +- [MicroPython Labs](https://lab-micropython.arduino.cc/) +- [Modulino MicroPython Package](https://github.com/arduino/arduino-modulino-mpy) + +## Connect the Modulino + +Before we start programming, we will need to connect our Modulino Movement to our Arduino board. For this we can follow the circuit diagram below: + +![Circuit Diagram]() + +## Modulino Movement Code Example + +Copy the code below and run it in Arduino MicroPython labs, while connected to our board. + +```python +from modulino import ModulinoMovement +from time import sleep_ms + +movement = ModulinoMovement() + +while True: + print("🏃 Accelerometer: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}".format(*movement.accelerometer)) + print("🌐 Gyroscope: x:{:>8.3f} y:{:>8.3f} z:{:>8.3f}".format(*movement.gyro)) + print("") + sleep_ms(100) +````