Skip to content

Embedded Programming

Arduino with C+ vs Raspberry Pico with Python

Katie and I decided to compare 2 microprocessors, with each using a different programming language and environment.

Board 1 - Arduino Nano with ATMega328 chip

Programming language - C+

Programming environment - Arduino IDE

Here is the workflow we use to program a Nano with the blink sketch:

  1. Download and open the Arduino IDE
  1. Open the blink example sketch
  1. Connect your Arduino Nano to your computer with usb cable
  1. Upload the sketch

Board 2 - Raspberry Pico with 2040 chip

Programming language - Micro Python

Programming environment - Thonny

Here is the workflow we used to program the Pico board:

  1. Hold down the 'bootsel' button, connect to your computer, release the 'bootsel' button
  1. The Pico appears as a new drive on your computer. Use Finder to check that it is detected correctly

    a_screenshot

  1. Download the UF2 file and drop it onto the Pico

    a_screenshot

  1. Write your code in the Thonny editor. We shall blink the built-in LED on pin 25:

    a_screenshot

  1. Save your file. Make sure to use .py as the file format and make sure to select your pico as the location for the save.

Comparison

  • Both boards are quick and easy, but the Pico is the slightly more simple of the two.
  • C+ is the more familiar programming language to us, but Python is easier to learn for newcomers.
  • Both platforms are well supported but there appear to be a greater number of libraries for Arduino
  • Arduino has a greater number of tutorials and documentation readily available.
  • Pico has the advantage of appearing as a drive on your computer. It would allow you to access the files on the Pico from a different computer.
  • Arduino Nano is £14. Arduino Nano clone is £4. Pico is £3.

Arduino IDE vs PlatformIO

Katie and I decided to test an alternative to the Arduino IDE. Platform IO is a plug-in that can be used within most code editors. My current editor of choice is Visual Studio Code, which is open-source and owned by Microsoft(weird combo, but there we go!) I've worked through the following tutorial:

Getting Started with PlatformIO
Get started with PlatformIO, a great alternative to the Arduino IDE. Examples with Arduino, ESP32 & XIAO microcontrollers.Article with references & code: htt…
https://www.youtube.com/watch?v=JmvMvIphMnY

Why use PlatformIO?

There are more features available on PlatformIO, compared to the Arduino IDE. This table below shows what is included in each option:

Features

FEATUREARDUINO IDEPLATFORM IO
Board managerYesYes
Code editorYesYes
Syntax highlighterYesYes
CompilerYesYes
UploaderYesYes
Library managerYesYes
Serial monitorYesYes
Version controlNoYes
Auto completeNoYes
DebuggerNoYes

It looks like a no-brainer to us. Version control through Git and a useful debugger is more than enough reason to use this new platform.

We followed the youtube tutorial above to do a simple blink sketch on an Arduino Nano. Everything was very straightforward and worked great.

wk8group_comp

Programming working

We used a blink sketch that was on python so get our rasberry pi to blink the led on and off.

Here is an image of the code we used and the resberry pi lighting up with the code that is on the screen.

wk8group_rasberry_pi_board wk8group_rasberrypi_python

Code for the programming

    import machine 
    import utime

    led_pin = machine.Pin (25, machine.Pin.OUT)

    while True: 
        led_pin.value(1) # turn led on
        utime.sleep(1)
        led_pin.value(0) # turn led off
        utime.sleep(1)

                
                  
                    


Last update: June 12, 2021