Week 3: Embedded Programming

xdd44, Sep. 25, 2024


Toolchains and Development Workflows (Group work with Zhi Ray Wang)

Arduino Nano RP2040 vs Raspberry Pi Pico

Processor:

Both Dual-core ARM Cortex-M0+, 133 MHz (same RP2040 chip).

Memory:

Both 264 KB of SRAM and external flash up to 16 MB

Connectivity:

Arduino Nano RP2040: Features built-in Wi-Fi and Bluetooth in the Arduino Nano RP2040 Connect version.

Raspberry Pi Pico: No built-in wireless connectivity (requires an external module).

Form Factor:

Arduino Nano RP2040: Smaller and fits the traditional Nano form factor, ideal for projects where space is a constraint.

Raspberry Pi Pico: Slightly larger, with more available I/O pins.

Conclusion:

The Arduino Nano RP2040 is a more integrated choice for beginners, while Raspberry Pi Pico is a much cheaper choice for simpler tasks.

Comparison of the two chips by SocialCompare

Demonstration of two systems - LED light controlled by bluetooth

When comparing the Bluetooth architecture between the Raspberry Pi Pico and the Arduino Nano RP2040 Connect, the Arduino Nano is more convenient because it has built-in Bluetooth, allowing for simpler integration with Bluetooth-based projects. This reduces potential issues or bugs when setting up Bluetooth functionality, as everything is integrated and supported through the ArduinoBLE library. On the other hand, the Pico does not come with built-in Bluetooth, requiring external modules, which adds complexity and could introduce more potential bugs in future projects.

Comparison of the two chips achieving LED control by WOKWI


2048 game running on Arduino driven dot matrix

I bought an Arduino R4 Wi-Fi to complete the individual assignment of this week.

When browsing WOKWI, I saw this example of comtrolling LED matrix, and I realized I can write a 2048 game running on it.

Control & Communication

The game requires control for at least the direction to which the player would like to move the tiles. I didn't buy any button/controller module for my board. Therefore I decided to test out the Wi-Fi module (ESP32) embedded in my board.

Basically, I ended up creating an assess point via WiFiS3.h library, so that I can host a server on Arduino to listen to controlling requests.

I implemented a client listener, so that I can send GET request as my command. The server will respond to command=X requests, where X is the command (W/A/S/D for directions), and send text respond. On the laptop side, I wrote a python script to listen to keyboard input and send corresponding requests.

I used the onboard led matrix to test my implementation by controlling the movement of one lit pixel.

Test of controlling movement of a pixel by keyboard via Wi-Fi, and Arduino responding updated position.

Display

Each LED matrix cell consists of 8x8 LED lights, therefore I referred to a pixel font and hard-coded the display of each number.

Also, in game 2048, there will be numbers with more digits. Therefore I implemented a rolling display for large numbers.

Test of rolling display & Combined controlling function

Game

The actual game functions are not hard to implement. I also added reset command and response of scores.

The complete Arduino code is here

Test of rolling display & Combined controlling function