This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If it is printed in the REPL, it means it works, and you're ready to take on bigger challenges!
To find out examples and more fundamental knowledge, please visit the [MicroPython with Arduino documentation](/learn/programming/arduino-and-python). Here you will find an introduction to this environment and useful examples to get started.
To find out examples and more fundamental knowledge, please visit the [MicroPython with Arduino documentation](/micropython). Here you will find an introduction to this environment and useful examples to get started.
***It is important to note that different Arduino boards have different implementations. This is mainly due to what microcontroller the board is based on. For example, to access digital pin 2, on the GIGA R1, you will need to use `'PA3'` (with the quotation marks). See more in [GIGA R1 Pin Map](#pin-map)***
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -24,7 +24,7 @@ To use the GIGA Display Shield, there are currently three supported alternatives
### Option 1: GFX Library
The [Arduino_GigaDisplay_GFX](https://github.com/arduino/Arduino_GigaDisplay_GFX) library is a layer library for the [Adafruit_GFX](https://github.com/adafruit/Adafruit-GFX-Library) graphic core library. This library makes it easy to draw geometrical shapes, printing values, drawing pixels and more.
The [Arduino_GigaDisplay_GFX](https://github.com/arduino-libraries/Arduino_GigaDisplay_GFX) library is a layer library for the [Adafruit_GFX](https://github.com/adafruit/Adafruit-GFX-Library) graphic core library. This library makes it easy to draw geometrical shapes, printing values, drawing pixels and more.
***To get started with the GFX library, visit the [GIGA Display Shield GFX Guide](/tutorials/giga-display-shield/gfx-guide).***
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To display an image on the screen we first need to define what that image that should be. Take the desired image, [convert it into the correct format](https://docs.lvgl.io/master/overview/img.html#online-converter) and place the image in the same folder as the sketch. Now use `LV_IMG_DECLARE(filename);`. For example the image we use will be named `img_arduinologo`.
To display an image on the screen we first need to define what that image that should be. Take the desired image, [convert it into the correct format](https://docs.lvgl.io/master/overview/image.html#online-converter) and place the image in the same folder as the sketch. Now use `LV_IMG_DECLARE(filename);`. For example the image we use will be named `img_arduinologo`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The below example requires uses the [Arduino_GigaDisplay_GFX](https://github.com/arduino/Arduino_GigaDisplay_GFX) library, and demonstrates how to change a boolean whenever you touch the screen. It implements the `millis()` function to limit the number of executions.
The below example requires uses the [Arduino_GigaDisplay_GFX](https://github.com/arduino-libraries/Arduino_GigaDisplay_GFX) library, and demonstrates how to change a boolean whenever you touch the screen. It implements the `millis()` function to limit the number of executions.
Anytime the screen is touched, the background and text color inverts (black and white).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
***Please note: the cluster size is defined at format time by the user and has some default values that can be changed by users following some rules. In the sketch above we are using the default size for a block that is set at 512 bytes by standards. This value is not the cluster size: that is calculated as the number of blocks per cluster. You may find more in depth information about cluster sizes [in this article](https://support.microsoft.com/en-gb/help/140365/default-cluster-size-for-ntfs-fat-and-exfat).***
***Please note: the cluster size is defined at format time by the user and has some default values that can be changed by users following some rules. In the sketch above we are using the default size for a block that is set at 512 bytes by standards. This value is not the cluster size: that is calculated as the number of blocks per cluster. You may find more in depth information about cluster sizes [in this article](https://web.archive.org/web/20240309213220/https://support.microsoft.com/en-us/topic/default-cluster-size-for-ntfs-fat-and-exfat-9772e6f1-e31a-00d7-e18f-73169155af95).***
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- The **[analogReference()](https://www.arduino.cc/reference/en/language/functions/analog-io/analogreference/)** is used to configure the reference voltage for analog input.
- The **[analogReadResolution()](https://www.arduino.cc/reference/en/language/functions/zero-due-mkr-family/analogreadresolution/)** is used to determine the resolution of the value returned by **analogRead()**.
- The **[analogReadResolution()](https://www.arduino.cc/reference/en/language/functions/analog-io/analogreadresolution/)** is used to determine the resolution of the value returned by **analogRead()**.
- The **[analogRead()](https://www.arduino.cc/reference/en/language/functions/analog-io/analogread/)** is used to set an analog pin to read the value from.
- Last but not least, the respective resolution divider value. For the present example it uses **4095** for 12-Bit resolution applicable for MKR WAN 1310. If it uses different resolution, such as 10-Bits, you will need to define it to **1023**.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
When using serial communication, allow the user to specify any `Stream` object, rather than hard-coding `Serial`. This will make your library compatible with all serial ports on boards with multiple (e.g., Mega), and can also use alternate interfaces like SoftwareSerial. The Stream object can be passed to your library's constructor or to a `begin()` function (as a reference, not a pointer). See [Firmata 2.3](http://www.firmata.org/wiki/Main_Page) or [XBee 0.4](https://github.com/andrewrapp/xbee-arduino) for examples of each approach.
When using serial communication, allow the user to specify any `Stream` object, rather than hard-coding `Serial`. This will make your library compatible with all serial ports on boards with multiple (e.g., Mega), and can also use alternate interfaces like SoftwareSerial. The Stream object can be passed to your library's constructor or to a `begin()` function (as a reference, not a pointer). See [Firmata 2.3](https://www.arduino.cc/reference/en/libraries/firmata/) or [XBee 0.4](https://github.com/andrewrapp/xbee-arduino) for examples of each approach.
When writing a library that provides byte-stream communication, inherit Arduino's `Stream` class, so your library can be used with all other libraries that accept `Stream` objects. If possible, buffer incoming data, so that `read()` immediately accesses the buffer but does not wait for more data to arrive. If possible, your `write()` method should store data to a transmit buffer, but `write()` must wait if the buffer does not have enough space to immediately store all outgoing data. The `yield()` function should be called while waiting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
***You can also check out the full list of examples in the [OpenMV's GitHub repository](https://github.com/openmv/openmv/tree/master/scripts/examples/10-Arduino-Boards).***
***You can also check out the full list of examples in the [OpenMV's GitHub repository](https://github.com/openmv/openmv/tree/master/scripts/examples/50-Arduino-Boards).***
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -11,7 +11,7 @@ All the compatible boards have a series of pins, most of these pins work as a ge
There are essentially two types of pins, analog and digital pins. Digital pins can be set to either HIGH (usually 5V or 3.3V) or LOW (0V). You can use that to e.g. read a button state or toggle an LED.
***Important: unfortunately, the MicroPython implementation does not match the regular pinout of your board. This means, that if you want to use for example, digital pin (5), it might be digital pin (27) on one board, or digital pin (14) on another. Please visit the [Board API article](/micropython/basics/board-api) to see what the pin map for your board is.***
***Important: unfortunately, the MicroPython implementation does not match the regular pinout of your board. This means, that if you want to use for example, digital pin (5), it might be digital pin (27) on one board, or digital pin (14) on another. Please visit the [Board API article](/micropython/basics/board-examples) to see what the pin map for your board is.***
## Digital Pins
Expand DownExpand Up
@@ -113,7 +113,7 @@ while True:
time.sleep_ms(500)
```
***If you are using an [Arduino Nano RP2040 Connect](https://store.arduino.cc/products/arduino-nano-rp2040-connect), you can also do the following: `adc = ADC("A4")`. For more information check out the example [here](http://docs.arduino.cc/micropython/basics/board-examples#analog-read).***
***If you are using an [Arduino Nano RP2040 Connect](https://store.arduino.cc/products/arduino-nano-rp2040-connect), you can also do the following: `adc = ADC("A4")`. For more information check out the example [here](http://docs.arduino.cc/micropython/basics/board-examples/#analog-read).***
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
***If you are unsure how to install external modules you can read up on it [here](https://docs.arduino.cc/micropython-course/course/introduction-python#external-modules)***
***If you are unsure how to install external modules you can read up on it [here](https://docs.arduino.cc/micropython/micropython-course/course/examples/#module-installation)***
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
***If you are unsure how to install external modules you can read up on it [here](https://docs.arduino.cc/micropython-course/course/introduction-python#external-modules)***
***If you are unsure how to install external modules you can read up on it [here](https://docs.arduino.cc/micropython/micropython-course/course/examples/#module-installation)***
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -66,7 +66,7 @@ In addition, some pins have specialized functions:
* Serial: RX and TX: these pins are used to receive (RX) and transmit (TX) TTL serial data.
* External Interrupts: all pins can be used as external interrupts. Keep in mind that you can’t use more than eight interrupt pins at the same time. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the [attachInterrupt()](https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/) function for details.
* PWM: pulse width modulation is available on all pins. The 12-bit PWM output resolution can be adjusted using the [analogWriteResolution()](https://www.arduino.cc/reference/en/language/functions/zero-due-mkr-family/analogwriteresolution/) function.
* PWM: pulse width modulation is available on all pins. The 12-bit PWM output resolution can be adjusted using the [analogWriteResolution()](https://www.arduino.cc/reference/en/language/functions/analog-io/analogwriteresolution/) function.
* SPI: a Serial Peripheral Interface (SPI) bus is available using pins 4 (MOSI), 5 (MISO), and 6 (SCK) and 7 (SS) but it is possible to change them and use other pins. For more information about it visit the [SPI library](https://www.arduino.cc/en/Reference/SPI).
* TWI: Two-wire interface (TWI) communication is available from the serial data line (SDA) and serial clock line (SCL) pins. TWI communication is supported using the [Wire library](https://www.arduino.cc/en/Reference/Wire).
* RESET. Bringing the reset line LOW will reset the microcontroller.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -80,7 +80,7 @@ The nRF52832 has 512 KB of Flash memory and 64 KB of SRAM. There is no onboard E
Each of the 14 digital pins on the Primo can be used as an input or output, using [pinMode()](https://www.arduino.cc/reference/en/language/functions/digital-io/pinmode/), [digitalWrite()](https://www.arduino.cc/en/Reference/DigitalWrite) , and [digitalRead()](https://www.arduino.cc/reference/en/language/functions/digital-io/digitalread/) functions. They operate at 3.3V. Each pin can provide or receive a maximum current of 14 mA. In addition, some pins have specialized functions:
* Serial: 0 (RX) and 1 (TX): Pins 0 and 1 are used to receive (RX) and transmit (TX) TTL serial data. On Primo TX and RX LEDs are missing but the ON LED blinks every time you send data over the Serial port of the nRF52
* External Interrupts: all pins (digital and analog) can be used as external interrupts except pins 0 and 1\. Keep in mind that you can’t use more than eight interrupt pins at the same time. These pins can be configured to trigger an interrupt on a low value, a rising or falling edge, or a change in value. See the [attachInterrupt()](https://www.arduino.cc/reference/en/language/functions/external-interrupts/attachinterrupt/) function for details.
* PWM: pulse width modulation is available on all digital pins except pins 0 and 1\. The 12-bit PWM output resolution can be adjusted using the [analogWriteResolution()](https://www.arduino.cc/reference/en/language/functions/zero-due-mkr-family/analogwriteresolution/) function.
* PWM: pulse width modulation is available on all digital pins except pins 0 and 1\. The 12-bit PWM output resolution can be adjusted using the [analogWriteResolution()](https://www.arduino.cc/reference/en/language/functions/analog-io/analogwriteresolution/) function.
* SPI: A serial peripheral interface (SPI) bus is available using pins 10 (SS), 11 (MOSI), 12 (MISO), and 13 (SCK) as well as using the onboard ICSP header. SPI communication is available using the [SPI library](https://www.arduino.cc/en/Reference/SPI).
* LED: There is a built-in LED connected to digital pin 9\. When the pin is HIGH value, the LED is on, when the pin is LOW, it's off.
The Primo has 6 analog inputs, labeled A0 through A5, each of which provide up to 14 bits of resolution (i.e., 16384 different values). By default they measure from ground to 3.3 volts, though it is possible to change the upper end of their range using the [analogReference()](https://www.arduino.cc/reference/en/language/functions/analog-io/analogreference/) function. A few additional pins are on the headers and those pins have specialized functions:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -60,7 +60,7 @@ OpenMV is a great platform for computer vision and machine learning projects.
Further down this article, you can find a lot of useful code examples that will help you to get started.
***You can also check out the full list of examples in the [OpenMV's GitHub repository](https://github.com/openmv/openmv/tree/master/scripts/examples/10-Arduino-Boards).***
***You can also check out the full list of examples in the [OpenMV's GitHub repository](https://github.com/openmv/openmv/tree/master/scripts/examples/50-Arduino-Boards).***
## Compatible Boards
Expand All
@@ -84,7 +84,7 @@ If you need help getting started with MicroPython on the **Nano 33 BLE** board,
-[Install MicroPython on your Nano BLE](/tutorials/nano-33-ble-sense/micropython-installation#arduino-nano-33-ble).
-[Getting started with OpenMV and Nano 33 BLE](/tutorials/nano-33-ble/getting-started-omv)
-[Nano 33 BLE Python® API guide](/tutorials/nano-33-ble/ble-python-api) (a collection of useful scripts).
-[Nano 33 BLE Python® API guide](/micropython/basics/board-examples/#nano-33-ble) (a collection of useful scripts).
***To reset the bootloader on the Nano 33 BLE board, double tap the reset button quickly. This will reset your board to factory setting.***
Expand All
@@ -96,7 +96,7 @@ If you need help getting started with MicroPython on the **Nano 33 BLE Sense** b
-[Install MicroPython on your Nano BLE Sense](/tutorials/nano-33-ble-sense/micropython-installation#arduino-nano-33-ble).
-[Getting started with OpenMV and Nano 33 BLE Sense](/tutorials/nano-33-ble-sense/getting-started-omv)
-[Nano 33 BLE Sense Python® guide](/tutorials/nano-33-ble-sense/ble-sense-python-api) (a collection of useful scripts).
-[Nano 33 BLE Sense Python® guide](/micropython/basics/board-examples/#nano-33-ble-sense) (a collection of useful scripts).
***To reset the bootloader on the Nano 33 BLE Sense board, double tap the reset button quickly. This will reset your board to factory setting.***
Expand All
@@ -106,7 +106,7 @@ If you need help getting started with MicroPython on the **Nano 33 BLE Sense** b
If you need help getting started with MicroPython on the **Nano RP2040 Connect** board, you can check out the tutorials below:
-[Install MicroPython on your Nano RP2040 Connect](/tutorials/nano-rp2040-connect/micropython-installation#arduino-nano-rp2040-connect)
-[Install MicroPython on your Nano RP2040 Connect](/micropython/basics/board-installation/#nano-rp2040-connect)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -7,7 +7,7 @@ description: 'The first steps to setting up your Arduino Fio'
The ATmega328P on the Arduino Fio comes preburned with a [bootloader](https://docs.arduino.cc/hacking/software/Bootloader) that allows you to upload new code to it without the use of an external hardware programmer. It communicates using the original STK500 protocol ([reference](http://www.atmel.com/dyn/resources/prod%5Fdocuments/doc2525.pdf), [C header files](http://www.atmel.com/dyn/resources/prod%5Fdocuments/avr061.zip)).
There are two ways you can upload new sketches to the Arduino Fio: you can use an FTDI USB-to-serial cable, or USB-to-serial adaptor board; or you can program it wirelessly, over a pair of XBee radios. If you're new to the XBee radios, it's helpful to know a bit about them before attempting the wireless programming. This [introduction](http://itp.nyu.edu/physcomp/Tutorials/XbeeBasics) may help.
There are two ways you can upload new sketches to the Arduino Fio: you can use an FTDI USB-to-serial cable, or USB-to-serial adaptor board; or you can program it wirelessly, over a pair of XBee radios. If you're new to the XBee radios, it's helpful to know a bit about them before attempting the wireless programming. This [introduction](https://web.archive.org/web/20140813203852/http://itp.nyu.edu/physcomp/Tutorials/XbeeBasics) may help.
You can also bypass the bootloader and program the ATmega328P with an external programmer; see [these instructions](https://docs.arduino.cc/hacking/software/MiniBootloader) for details.
Expand DownExpand Up
@@ -93,7 +93,7 @@ If you're running Windows, you have to make a slight change to the driver prefer
## How to configure XBee modems
You can configure your radios using a terminal application, or using X-CTU on Windows, or you can use the [Fio XBee Config Tool](//www.arduino.cc/en/uploads/Main/XBeeConfigTool.zip). This is a modified version of Shigeru Kobayashi's [XBeeConfigTool](http://funnel.googlecode.com/files/XBeeConfigTool.zip).
You can configure your radios using a terminal application, or using X-CTU on Windows, or you can use the [Fio XBee Config Tool](//www.arduino.cc/en/uploads/Main/XBeeConfigTool.zip). This is a modified version of Shigeru Kobayashi's XBeeConfigTool.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -110,7 +110,7 @@ Pressing the Reset button on the M0 causes the SAMD21 to reset as well as resett
#### ADC and PWM resolutions
The M0 has the ability to change its analog read and write resolutions (defaults to 10-bits and 8-bits, respectively). It can support up to 12-bit ADC/PWM and 10-bit DAC resolutions. See the [analog write resolution](https://www.arduino.cc/reference/en/language/functions/zero-due-mkr-family/analogwriteresolution/) and [analog read resolution](https://www.arduino.cc/reference/en/language/functions/zero-due-mkr-family/analogreadresolution/) pages for information.
The M0 has the ability to change its analog read and write resolutions (defaults to 10-bits and 8-bits, respectively). It can support up to 12-bit ADC/PWM and 10-bit DAC resolutions. See the [analog write resolution](https://www.arduino.cc/reference/en/language/functions/analog-io/analogwriteresolution/) and [analog read resolution](https://www.arduino.cc/reference/en/language/functions/analog-io/analogreadresolution/) pages for information.
For more details on the Arduino M0, see the [hardware page](https://arduino.cc/en/Main/ArduinoBoardM0).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -219,4 +219,4 @@ You are not limited to running one sketch at a time and can run multiple sketche
### Troubleshooting
If something goes wrong in this installation process you can let us know [on the Arduino Forum](http://forum.arduino.cc/index.php?board=105.0). Keep in mind that this guide has been tested in depth only on the [Intel Nuc ](https://www.intel.com/content/www/us/en/products/boards-kits/nuc.html)and the[ UP2 Board.](https://www.intel.com/content/www/us/en/products/boards-kits/nuc.html)
If something goes wrong in this installation process you can let us know [on the Arduino Forum](https://forum.arduino.cc/c/software/intel-based-platforms/144). Keep in mind that this guide has been tested in depth only on the [Intel Nuc ](https://www.intel.com/content/www/us/en/products/boards-kits/nuc.html)and the[ UP2 Board.](https://www.intel.com/content/www/us/en/products/boards-kits/nuc.html)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In this tutorial you will learn how to communicate with a computer using a MAX3323 single channel RS-232 driver/receiver and a software serial connection on the Arduino. A general purpose software serial tutorial can be found [here](http://www.arduino.cc/en/Tutorial/SoftwareSerial).
In this tutorial you will learn how to communicate with a computer using a MAX3323 single channel RS-232 driver/receiver and a software serial connection on the Arduino. A general purpose software serial tutorial can be found [here](/tutorials/communication/SoftwareSerialExample).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This technique has the advantage that it can use any digital output pin. In addition, you have full control the duty cycle and frequency. One major disadvantage is that any interrupts will affect the timing, which can cause considerable jitter unless you disable interrupts. A second disadvantage is you can't leave the output running while the processor does something else. Finally, it's difficult to determine the appropriate constants for a particular duty cycle and frequency unless you either carefully count cycles, or tweak the values while watching an oscilloscope.
A more elaborate example of manually PWMing all pins may be found [here](http://www.arduino.cc/playground/Main/PWMallPins).
A more elaborate example of manually PWMing all pins may be found [here](http://www.arduino.cc/playground/Main/PWMallPins/).