Embedded programming
Click here to see the group assigment
Common Syntax Rules
Python: Python simplifies variable usage and data type declaration. Variables are dynamically typed, which means the interpreter infers the data type based on the assigned value, making Python very flexible and easy to use for developers.-Python's control structures are designed for readability and simplicity. The use of indentation to define block scopes makes Python code very clean and easy to understand, even for beginners.
- Functions in Python are defined using the def keyword. Python supports a variety of function arguments and allows for easy definition of default, keyword, and variable-length arguments, facilitating flexible function calls.
C++: In C++, variables must be declared with an explicit data type before they are used. This static typing adds to the language's robustness, enabling compile-time type checking and optimization that can lead to more efficient code execution.
-C++ employs braces ({}) to define the scope of control structures, providing a familiar syntax for those with experience in C or similar languages. It supports a wide range of control flow statements, allowing for complex decision-making and looping with efficiency.
- C++ functions must specify the return type explicitly. They provide a powerful feature set, including overloading, default parameters, and templates, which allow for writing generic and reusable code components.
Let´s to program "XIAO RP 2040" board
Architectures are basically families of chips, "architecture" refers to the fundamental design and structure of the computing core and its instruction set. Think of it as the blueprint that dictates how a microcontroller or processor is built and how it processes information. To simplify it imagine you're building a house. The architecture of the house dictates the overall design, how rooms are laid out, what materials are used, and how different parts of the house connect with each other. Similarly, in microcontrollers and processors, the architecture defines how the device is designed internally, how it performs computations, and how different components within it communicate and work together.
There are 14 GPIO PINs with input, output and interrupt functions on Seeed Studio XIAO RP2040, in which there are 11 digital pins, 4 analog pins, 11 PWM pins, 1 I2C interface, 1 UART interface, 1 SPI interface and 1 SWD Bonding pad interface.
ARDUINO
We can use the previous image as a reference to locate the PINS that we want to program.1.-To reset the card We press the "B" button while connecting the card to the computer with a USB-C cable.
2.-We open Arduino and look for the UF2 board and then select the "XIAO RP 2040" card.
nd we are ready to start programming our card!
How to turn on an LED | The evidence |
how to light two leds with time variation | The evidence |
How to make an LED turn on by pressing a button | The evidence |
How to get two LEDs to lower their brightness intensity little by little | The evidence |
Communication with remote wired
I used a code to turn on a Led in serial communication
In this exercise the goal was for one of the LEDs to turn on with the number "1" and turn off with "0"Click to download code
You could even communicate with another board
You can see a communication exercise with "I2C protocol" in week 14
MU - CIRCUIT PYTHON
1.- The first step is download the file to load
You can download HERE
2.-Selec MODE to program
"MU" allows you to program in different modes but, for this exercise I selected CircuitPython
3.-Load the "CODE" file
A now, U're ready to program the XIAO en CircuitPython
HOLA MUNDO!
How a Loop works
How to make an LED blink | The evidence |
How to make an LED turn on by pressing a button | The evidence |
How to make two LED turn on by pressing a button | The evidence |
How to import a new library
To import a new library, we download Bundle for Version 8.x and from the "lib" folder we copy the following files:
neopixel.mpy
adafruit_pixelbuf.mpy