dummy


4. EMBEDDED PROGRAMMING


This week we got to deep our toes in "Programming". We have been introduced to the world of Microcontrollers, they are little computers where we can programm an espcific task and it will do it whith the help of software and hardware. These little "minicumputers" typically include a processor, memory and input/output peripherals.
We will be exploring the Seeed XIAO RP2040, it is as big as a coin.


HERO IMAGE

size

ASSIGNMENTS

-Group Assignemt

-Individual Assignment

GROUP ASSIGNMENT

For this assignment we met with my fellow students and Programmed some tasks in Arduino, then each of us programmed the same task in a different Coding Program.
From Fab Lab group I am the one with less experience with Coding or Programming....I would say...NOT EXPERIENCE AT ALL. So we took this opportunity to introduce me to the Programming world with a "Friendly" coding program: MICRO:BIT Microsoft's MakeCode editor.

This is a very visual program meant to introduce children into programming without writing the codes but working with visual blocks that will edit and compound the task we want the Microcontroller to do.

This is a tutorial from Micro:Bit, flashing heart.


size
size

I have to say that comparing the two programs was easy to do, but at least it was fun. The programming in Micro:Bit is done directly into their webpage, there is not need of download any program, but it is important to have their brand Microcontroller, which is a bit expensive compared to the Seeed XIAO RP2040 Microcontroller.

I did some of the simple programing for the Neopixels LEDs in Arduino and Micro:bit, I would say the way the lights move are not "exactly" the same but quite near.

Micro:Bit

size

Arduino


size

Both lights on with Micro:Bit and Arduino


You can see HERE more about the group assigment, where we compare more in detail different Programming Languages.


INDIVIDUAL ASSIGNMENT

-Microcontroler Program and Microcontroller Data Sheet

Seed XIAO RP2040 Microcontroller:

Before Programming it is important to know the bulding structure of the Microcontrollers and know its parts, this info can be found extensevely in the Wiki SEEED STUDIO page.

size size

We can see in this front images the Microcontroller has a Type C connection, power led, Internal Users LEDs, a Microporcessor at the center, several PINs to connect either, Analog or Digital input/output, a reset and Boot buttons, the last one is used very frequently when Arduino sends a ERROR message because the chip can loose connection with the computer, then we have to long press "B" button to solve it and try to download the program again.

size

In the SeeedStudio wiki page, you can find the PDF link to the complete "RP2040 Datasheet"

Installing the Arduino Software to program:

In the SeeedStudio wiki page, you can find too a link to go STEP BY STEP to install Arduino in your computer.

  1. Download the program from HERE
  2. Launch the application
  3. Add Seeed Studio Microcontroller to the Arduino IDE
  4. Navigate to File>Preferences and fill Additional Boards Manager URLs

    size
  5. Navigate to Tools>Board>Board Manager>RP2040 abd select the last version of "Raspberry Pi PicoRP2040" And install it
  6. select your board and port, Tools>Board, find "seeed Studio XIAO RP2040" and select it.
  7. size
    size

-Ready to program the XIAO RP2040

Interact with local input

Arduino has some examples for us to start with the programming we just have to change some inputs to it like the Pin connections as we have them in our phisical Microcontroller and write this on the program, this is an example

-Blink (local Input Interaction)

size
size

Here we just have to connect the Microcontroler to the computer and download the code to the Microcontroler, this is the result:

-Servo Knob Controlled using a potentiometer(input-Output)

If we need extra functionalities that are not included in the Arduino library, we need to include them.
Select Sketch>Inlcude libray> Manage Libraries, then in the open library window write what you are looking for, in this case Servo by Michael Margolis, Arduino, version 1.1.8, and install it.

We can open now from File>Examples>Servo>Knob

size

We connect the servo and the potentiometer to the Microcontroller like in the following diagram:

size

when programing with this sketch, we should write the number of the pin where the potentiometer is connected to the Microcontroller, in this case is A0, and the Servo motor is connected to D9.
The val command is to convert the analog voltage to digital voltage. This is the result:


-Comunicate remotely

This programming connects a HC-05, which is a Bluetooth Transceiver Module with a external LED.

size

Here what the programming says is (in my words):

This is how it looks


Blink in ArduinoHERE

Controlling a servo using a potentiometer in ArduinoHERE