6. Embedded Programming

For this week's practice we were asked to write a program for a development board with a microcontroller. This must have exits and entrances. In addition to being able to communicate. And as an extra, use different languages and development environments. To carry out this practice, I used Arduino and Python, in addition to which I designed and manufactured a PCB to connect to the board that we manufactured in week four

The idea for this project was to create a pin-pong type game with several LEDs in a row, this would have nine LEDs and two buttons. I started with the design of the PCB, and once I had the plan, I began the task of making the program. I first started with Arduino since I have used it in the past and having the code ready I just passed it to the Python syntax

Arduino (C++)

Arduino is an open source platform used for creating electronics projects. The Arduino development environment is an easy-to-use software that allows you to write, compile, and upload code to the board's microcontroller. This software is compatible with operating systems such as Windows, macOS and Linux. Programming is done in a language similar to C/C++, which makes it easy to learn and use, especially for those who already have experience in these languages.

Circuit Python

Python is a general-purpose, interpreted, high-level programming language designed with a focus on code readability. It is a multi-paradigm programming language, which means that it supports different programming styles, such as object-oriented, imperative, functional and procedural programming. This makes it extremely flexible and suitable for a wide range of applications. Python runs on a variety of platforms, including Windows, macOS, Linux, and has been ported to Java and .NET in virtual environments.

Syntax comparison

ARDUINO (C++) PHYTHON
Control Structures Opening and closing of keys Tab hierarchy
Variables Variable type specification int, float, char, etc automatically determines the type of variable
Comments //comment and */more comments/ * #comment and '''more commnets'''
Functions Specify the return Using def with arguments
Delay (import time) time.sleep(1) one second Delay(1000) one second
Input #define push 25
pinMode(push, INPUT)
x = digitalio.DigitalInOut(board.GP25)
push.direction = digitalio.Direction.INPUT
Output #define led 25
pinMode(led, OUTPUT)
x = digitalio.DigitalInOut(board.GP25)
led.direction = digitalio.Direction.OUTPUT
Write digitalWrite(led,HIGH)
digitalWrite(led,LOW)
led.value = True
led.value = False
Read digitalRead(push) push_value = push.value
Printing Serial.prinln("hello, wold") print("hello, wold")

for more information visit the GROUP PAGE

Programming

To start programming our microcontroller, we first need to prepare our microcontroller for the programming language we are going to use. To do this on my SEED XIAO rp2040 microcontroller, you will press the B button on the board and, while keeping it pressed, connect it to the computer. This folder will not appear on the computer. This active the mode bootloader

for Arduino

In this mode, we will open the Arduino program and look for the following option

We will look for the seeed xiao rp2040 board and we will give ok

Now the board recognizes us and we can load the code from the Arduino program.

arduino

for Python

Inside the board folder, we will drag the bootloader for python, and we wait for the folder to open again

The folder should look like this

In mu Editor we will load the code file and that's it, we can load code if you press the save button

mu Editor

Having the program ready and the Bootloader installed on the micro controller. Just upload the code for it to work, the following are the programs I created in Arduino and Python that do exactly the same thing

PCB MANUFACTURING

design

Here I show the PCB manufacturing process for this practice

design

For the design of the pcb, I used the fusion 360 program, with its electronic design tool, I began by creating a plan of the size of the pcb and using the plan

design

Find the schematic of the missing components and add them in fusion, also activate more components that the program has

design

I started adding all the components I was going to use like LEDs and resistors. Using the Connect tools, I added names to the connections.

design

With all the components linked, I moved on to the actual display so I could arrange the components into place. Use the alignment tools to accommodate them.

design

I set up the track configuration and used the Autoroute tool to make the connections.

design

To generate the PCB cut images, I typed export in the top bar, image and it gave it a resolution of 2000. I exported one for the tracks and one for the cut

design

Having the cutting images, use the CNC Drill to manufacture the PCB. For more information visit week four

design

Having the PCB and the components, I started soldering to finish with the PCB.


final result

Loading either of the two codes, we would obtain the same result in terms of the operation of the PCB. Within the program terminals we can see how many times the light bounces and the total points that were obtained.