This week's assignment was:

  • GROUP ASSIGNMENT:
  • - Browse through the data sheet for your microcontroller

    - Compare the performance and development workflows for other architectures

  • INDIVIDUAL ASSGINMENT:
  • - Write a program for a microcontroller development board that you made to interact (with local input &/or output devices) and communicate (with remote wired or wireless devices)

    - EXTRA CREDIT: Use different languages &/or development environments

    - EXTRA CREDIT: Connect external components to the board

    ORGANIZATION

    Here I show how I organized myself for this week.

    Wednesday 28th: Fab Academy classes
    Thursday 29th: Meeting and feedback with instructors. Progress of research group work
    Friday 1th: Meeting with colleagues from the FAB ACADEMY to finish the group assignment and learn about their research. Make documentation No. 1
    Saturday 2th: Enter OPEN GLOBAL TIME. Move forward with the individual programming assignment with quentorres.
    Sunday: 3th: Documentation and commit of everything done until Saturday.
    Monday 4th: Advance and finish the individual assignment with all the inputs and outputs that we have in the FAB LAB. Documentation No. 3
    Tuesday 5th: Documentation review, add some small changes and final commit.

    GROUP ASSIGNMENT

    Here I leave the link to go to the group assignments page.

    Clic here to visit the WEEK 6 GROUP ASSIGNMENT PAGE

    To carry out the group work, on Thursday 02/29/2024 all the students met with our instructors to talk about the group and individual work and clarify some doubts we had for the week. They helped us a lot by giving us a short introduction to programming and explaining the assignments.

    SEEED STUDIO XIAO RP2040 MICROCONTROLLER

    INTRODUCTION

    For the FAB ACADEMY 2024, they recommended that we use the SEEED STUDIO XIAO RP2040, which will help us carry out all our assignment programming and also our final work. It is a very powerful microcontroller that, due to its characteristics, allows us to program due to its versatility.

    FEATURES

    1. Raspberry Pi RP2040 Microcontroller: The RP2040 is an ARM Cortex-M0+ dual-core microcontroller running at 133 MHz. It offers a wide range of peripherals and exceptional performance for low-power applications.

    2. USB-C Connectivity: The XIAO RP2040 board uses a USB-C port for power and programming, making it easy to connect and program the board to a variety of systems.

    3. Arduino Compatibility: The XIAO RP2040 board is compatible with the Arduino development environment, allowing users to easily program it using the Arduino programming language and the wide range of libraries available.

    4. Small form factor: The XIAO RP2040 board has a small form factor, making it ideal for applications where space is limited, such as wearables, wearable devices and sensors.

    5. Support for multiple communication interfaces: The XIAO RP2040 board features a variety of communication interfaces, including UART, SPI, I2C and USB, making it suitable for a wide range of embedded electronics and IoT applications.

    DATA SHEET SEEED STUDIO XIAO RP2040

    Seed Studio XIAO RP2040 supports different programming languages such as C++, MicroPython, Python, Arduino IDE. It is also compatible with the Raspberry Pi RP2040 ecosystem and here I leave you some characteristics of the microcontroller:

    - Microcontroller: RP2040 dual-core ARM Cortex-M0+ at 133 MHz.

    - Memory: 264 KB of RAM and 2 MB of QSPI flash memory.

    - Connectivity: USB-C for power and programming.

    - Compatibility: Compatible with Arduino and CircuitPython development environment.

    - Communication interfaces: UART, SPI, I2C, USB.

    - Form factor: Small, ideal for limited space applications.

    - Power: 3.3V.

    - Peripherals: 30 GPIO pins, 2 status LEDs.

    - Software Support: Support for multiple development environments, including Arduino, CircuitPython and MicroPython.

    - Hardware Support:Support for a wide range of sensors and actuators.

    - Applications: Ideal for IoT projects, embedded electronics, wearables and portable devices.

    There are 14 GPIO PINs on Seeed Studio XIAO RP2040, which include 11 digital pins, 4 analog pins, 11 PWM Pins,1 I2C interface, 1 UART interface, 1 SPI interface, 1 SWD Bonding pad interface.

    Here I leave the DATASHEET link of the microcontroller so that we can learn more features.

    SEEED STUDIO XIAO ESP32-C3 MICROCONTROLLER

    INTRODUCTION

    Another microcontroller that they recommended to use is the SEEED STUDIO XIAO ESP32-C3 , which has very similar characteristics to the XIAO RP2040, however, it has some differences that will be explained later.

    FEATURES

    1. ESP32-C3 Microcontroller: The ESP32-C3 is a single-core RISC-V microcontroller running at 160 MHz. It offers a wide range of peripherals and exceptional performance for low-power applications.

    2. USB-C Connectivity: The XIAO ESP32-C3 board uses a USB-C port for power and programming, making it easy to connect and program the board to a variety of systems.

    3. Arduino Compatibility: The XIAO ESP32-C3 board is compatible with the Arduino development environment, allowing users to easily program it using the Arduino programming language and the wide range of libraries available.

    4. CircuitPython and MicroPython Support: In addition to being compatible with the Arduino development environment, the XIAO ESP32-C3 board also supports CircuitPython and MicroPython, two popular programming languages for microcontrollers. This expands development options and allows users to choose the environment that best suits their needs and preferences.

    5. Support for Bluetooth and Wi-Fi: The ESP32-C3 has wireless connectivity capabilities, allowing the XIAO ESP32-C3 board to communicate with other devices via Bluetooth and Wi-Fi. This is especially useful for IoT applications and creating network-connected devices.

    DATA SHEET SEEED STUDIO XIAO ESP32-C3

    Seed Studio XIAO RP2040 supports different programming languages such as C++, MicroPython, Python, Arduino IDE. It is also compatible with the Raspberry Pi RP2040 ecosystem and here I leave you some characteristics of the microcontroller:

    - Microcontroller:ESP32-C3, a single-core RISC-V microcontroller running at 160 MHz.

    - Memory: 400 KB de RAM y 384 KB de memoria flash.

    - Connectivity: USB-C for power and programming, and support for Bluetooth and Wi-Fi.

    - Compatibility: Compatible with Arduino, CircuitPython and MicroPython development environments.

    - Communication interfaces: UART, SPI, I2C, USB and microSD card support.

    - Form factor: Small, ideal for limited space applications.

    - Power: 3.3V.

    - Peripherals: Connector for external antenna, connector for lithium battery and 30 GPIO pins.

    - Software Support: Support for multiple development environments, including Arduino, CircuitPython and MicroPython.

    - Applications: Ideal for IoT projects, embedded electronics, wearables and portable devices.

    There are 11 digital I/O that can be used as PWM pins and 6 analog I/O that can be used as ADC pins. It supports all three common serial interfaces such as UART, I2C, and SPI.

    Here I leave the DATASHEET link of the microcontroller so that we can learn more features.

    COMPARISON WITH OTHER ARCHITECTURES

    COMPARISON TABLE

    To make the comparison table of the different microcontrollers that the FAB ACADEMY recommended to us, we held a virtual meeting to talk, share information and we assigned ourselves by group for the research. Here I leave a screenshot of the summary table of everything done in the group. After that, I leave a final conclusion of what I learned and how important it is to know about other microcontrollers that we may use in our final project.

    Here I leave the PDF FILE of the research carried out in summary.

    CONCLUSION

    All microcontrollers have unique features and can be suitable for different types of projects. For example, the ATTINY412 is ideal for low-power applications due to its low power consumption and wide range of peripherals. The SAMD11C is a great choice for projects that require high processing power and a wide range of communication interfaces. The XIAO RP2040 and XIAO ESP32-C3 are excellent options for IoT and embedded electronics projects due to their wireless connectivity and wide range of peripherals. The ATTINY1624 is ideal for budget-friendly projects due to its low cost and wide range of peripherals. Overall, choosing the right microcontroller will depend on the specific needs of your project, such as performance, connectivity, power consumption, and cost.

    We carried out the comparison of microcontrollers virtually where we met until very late, but we learned a lot about their differences, we learned to know more programming and electronics terms. Finally, here is a photo of us when we finished the group work, all very tired but with the strength to continue with the FAB ACADEMY.

    INDIVIDUAL ASSIGNMENT

    To develop the individual work it was difficult where to start since I have zero knowledge in programming. For this reason, I joined the OPEN GLOBAL TIME on Saturday 03/02/2024 where, especially the teacher Adrian and Rico, explained to us how we could work, what the objective of the assignments is and help us see if we accomplished something. On my part I had nothing because I didn't know where to start. The meeting helped me a lot and they recommended me to "PLAY" with the Quentorres and programming the LEDs they have.

    Here I have a photo of the QUENTORRES where they recommended soldering a component to be able to program different IMPUTS or OUTPUTS.

    LED PROGRAMMING WITH ARDUINO IDE

    INSTALL AND CONFIGURATION ARDUINO IDE

    To start programming QUENTORRES components I will start using the ARDUINO IDC that we were recommended to use for beginners. From here I will show different programming that I did with the LEDs that the board has. First of all, we are going to install the ARDUINO.IDC program and from there start programming.

    After installing the program, we need to configure to be able to program the XIAO RP2040, so we have to follow the following steps:

    Being in the program we go to FILES/PREFERENCES , here we will add 2 links so that the program can download all the information about the XIAO RP2040. Here I leave the 2 links that you need to copy and paste in the ADDITIONAL BOARDS section.Finally we click OK and it will begin downloading all the necessary information.

    PACKAGE RP2040

    PACKAGE ESP32

    Then we go to TOOLS/BOARD/BOARDS MANAGER , a tab will appear where we will put the word PICO and we will install the document called RASPBERRY PI PICO / RP2040 .

    Finally, we look in TOOLS/BOARD/RASPBERRY PI PICO/RP2040 and look for our SEEED XIAO RP2040 processor. This confirms that the installation is correct and we can start programming.

    BLINK A LED

    We will start to BLINK the first LED that is connected to PIN 26 or D0 . This without activating something, just programming a simple blink and seeing if it works.

    To perform the BLINK , we can start with an example that the ARDUINO IDE has. To do this, we can go to FILES/EXAMPLES/01.BASICS/BLINK. Here an ARDUINO IDE tab will open with the name BLINK. Here we can start programming the LED BLINK

    To program in ARDUINO IDE I understood that we have 3 important parts. The DEFINITION, VOID SETUP and VOID LOOP. Where in the first we have to define the PIN where the PIN is located; In VOID SETUP we set the LED as the output and in VOID LOOP we set the time and blink that the LED will have.

    After checking that everything is fine, we click on VERIFY in the upper left and after that, we click on UPLOAD where we load the information into QUENTORRES and we will see the magic.

    Here I leave the code for ARDUINO IDE

                                
                                    // define led acording to pin program
                                    int led = 26;
                                    void setup() {
                                    // initialize digital pin led as an output
                                    pinMode(led, OUTPUT);
                                    }
                                    void loop() {
                                    digitalWrite(led, HIGH);   // turn the LED on 
                                    delay(1000);               // wait for a second
                                    digitalWrite(led, LOW);    // turn the LED off
                                    delay(1000);               // wait for a second
                                    }
                                
                            

    We can see that the LED on pin 26 or D0 does BLINK according to the data mentioned in the program.

    INPUT

    BUTTON PROGRAMMING

    For the following programming we will make the button that we have in PIN 27 or D1 turn on the LED of PIN 26 or D0 that we have and when pressed it will have to blink for 3 times and then turn off. To do this, we will follow the same steps as the previous exercise, we will only add the button PIN and see if it is possible.

    In the first part, we specify the LED and BUTTON pins, along with their state and intensity variables. In the second part we add the 2 BUTTON pins and specify which one is the OUTPUT and INPUT. In the third part, we add the number of blinks that the LED will make when pressing the button and finally, set a condition when not pressing the button, the LED will be off.

    Here I leave the programming code for ARDUINO.IDE when pressing the button

                                
                                    const int ledPin1 = 26;//first light  RP2040 pin 0
                                    const int buttonPin = 27;// button pin  RP2040 pin 1 
                                    int buttonState = 0;//initial state of the button
                                    int i = 0; //variable intensity led
    
                                    void setup() { //declaration of inputs and outputs
                                    pinMode(ledPin1, OUTPUT);
                                    pinMode(buttonPin, INPUT);
                                    }
                                    void loop() {
                                    buttonState = digitalRead(buttonPin);// we read the state of the button
                                    if (buttonState == HIGH) { //if we press the button
                                    digitalWrite(ledPin1, HIGH);
                                    delay(500);                       
                                    digitalWrite(ledPin1, LOW);    
                                    delay(500);
                                    digitalWrite(ledPin1, HIGH);
                                    delay(500);                       
                                    digitalWrite(ledPin1, LOW);    
                                    delay(500);
                                    digitalWrite(ledPin1, HIGH);
                                    delay(2000);                        
                                    digitalWrite(ledPin1, LOW);    
                                    delay(1000);
                                    
                                    }
                                    else {  //if we don't press the button
                                    digitalWrite(ledPin1, LOW);
                                    }
                                    }
                                
                            

    We can see that the LED flashes 3 times when the button is pressed. Here I demonstrate the video.

    SEQUENCE PROGRAMMING WITH BUTTON

    For the next exercise we will do that, by pressing the button, we will have a series of turning on all the QUENTORRES LEDs, where the sequence will be repeated 4 times. The sequence will have this PIN LED D0; PIN LED D6 and PIN LED D7 and the shutdown will be carried out in reverse and all this will be repeated 4 times. In addition, we will add a message that, when we press the button, a “HELLO” message will appear in the SERIAL MONITOR of the Arduino IDE. Here the code and programming result

    Here I leave the programming code made that works very well for me. You can see the video.

                                
                                    const int ledPin =  D0;      // the number of the LED pin
                                    const int ledPin1 =  D6;
                                    const int ledPin2 = D7; 
                                    const int buttonPin = D1;     // the number of the pushbutton pin 
                                    int buttonState = 0;         // variable for reading the pushbutton status
                                    
                                    void setup()
                                    {
                                    Serial.begin(9600);
                                    pinMode(buttonPin, INPUT);
                                    pinMode(ledPin, OUTPUT);
                                        pinMode(ledPin1, OUTPUT);
                                        pinMode(ledPin2, OUTPUT);
    
                                    }
    
                                    void loop()
                                    { 
                                        buttonState = digitalRead(buttonPin);
                                        if (buttonState == HIGH) {
                                            Serial.print("Hola");
                                            for (int i=0; i <= 3; i++)
                                            {
                                                delay(500);
                                                digitalWrite(ledPin, HIGH);
                                                delay(500);
                                                digitalWrite(ledPin1, HIGH);
                                                delay(1000);
                                                digitalWrite(ledPin2, HIGH);
                                                delay(1000);
                                                digitalWrite(ledPin2, LOW);
                                                delay(1000);
                                                digitalWrite(ledPin1, LOW);
                                                delay(1000);
                                                digitalWrite(ledPin, LOW);
                                                
                                            }
                                    } else {
                                            digitalWrite(ledPin, LOW);
                                            digitalWrite(ledPin1, LOW);
                                            digitalWrite(ledPin2, LOW);
                                        }
                                    }
                                
                            

    From the previous code, we can start playing and change the LED lighting sequence, now I will change the sequence and we will see that the lighting changes when the button is pressed. We only need to change the top part of the above file and we can see the changes.

                                
                                    const int ledPin =  D0;      // the number of the LED pin
                                    const int ledPin1 =  D7;
                                    const int ledPin2 = D6; 
                                    const int buttonPin = D1;     // the number of the pushbutton pin 
                                    int buttonState = 0;         // variable for reading the pushbutton status
                                
                            

    OUTPUT

    ULTRASOUND PROGRAMMING

    For the next test we will do it with an output that is ULTRASOUND, in this case we will use it to measure the distance between the objects. The idea is to see how it works. Here I leave the programming code.

    Here I leave a programming code where with the help of CHATGPT I was able to obtain and we can see the results.

                                
                                    // Define the pins to be used
                                        const int trigPin = 2; // Output pin of the ultrasonic sensor
                                        const int echoPin = 3; // Input pin of the ultrasonic sensor
    
                                        // Define variables to store the times
                                        long duration;
                                        int distance;
    
                                        void setup() {
                                        // Initialize the pins as input or output
                                        pinMode(trigPin, OUTPUT);
                                        pinMode(echoPin, INPUT);
    
                                        // Initialize serial communication
                                        Serial.begin(9600);
                                        }
    
                                        void loop() {
                                        // Send a 10-microsecond pulse to the output pin
                                        digitalWrite(trigPin, LOW);
                                        delayMicroseconds(2);
                                        digitalWrite(trigPin, HIGH);
                                        delayMicroseconds(10);
                                        digitalWrite(trigPin, LOW);
    
                                        // Measure the time it takes for the echo to arrive
                                        duration = pulseIn(echoPin, HIGH);
    
                                        // Calculate the distance in centimeters
                                        distance = duration * 0.034 / 2;
    
                                        // Print the distance to the serial console
                                        Serial.print("Distance: ");
                                        Serial.print(distance);
                                        Serial.println(" cm");
    
                                        // Wait a moment before repeating
                                        delay(1000);
                                        }
                                
                            

    MOTION SENSOR TEST

    For the next test we will do it with an output that is MOTION DIRECTION DISTANCE 5-7m, in this case we will use it to detect movement within the range that the component has. Here I show you how we installed it and leave the programming code.

    Here we can see how the sensor begins to detect movement and shows it through No. 1 and when there is no presence of movement it changes to No. 0, so we can confirm that the programming and the sensor work.

    Here I leave a programming code where with the help of CHATGPT I was able to obtain and we can see the results.

                                
                                    // Define the pin to be used
                                        const int pirPin = 2; // Pin of the motion sensor
    
                                        void setup() {
                                        // Initialize the pin as input
                                        pinMode(pirPin, INPUT);
    
                                        // Initialize serial communication
                                        Serial.begin(9600);
                                        }
    
                                        void loop() {
                                        // Read the value of the motion sensor pin
                                        int motion = digitalRead(pirPin);
    
                                        // Print the value to the serial console
                                        Serial.println(motion);
    
                                        // Wait a moment before repeating
                                        delay(1000);
                                        }
                                
                            

    STANDARD SERVO MOTOR

    Finally we will try to program a STANDARD SERVO MOTOR , in this case we will make the servo present a movement of 180° and return again. The idea is to check if both the programming and the component work. Here I show you its connection, its programming code and the movement it performs.

    Here I leave a programming code where with the help of CHATGPT I was able to obtain and we can see the results.

                                
                                    #include 
    
                                        // Define the pin for the servo
                                        const int servoPin = 2;
                                        
                                        // Create a Servo object
                                        Servo myServo;
                                        
                                        void setup() {
                                          // Initialize the Servo object
                                          myServo.attach(servoPin);
                                        }
                                        
                                        void loop() {
                                          // Move the servo from 0 to 180 degrees with a delay
                                          for (int angle = 0; angle <= 180; angle += 1) {
                                            myServo.write(angle);
                                            delay(15);
                                          }
                                          delay(1000); // Wait for a second
                                        
                                          // Move the servo from 180 to 0 degrees with a delay
                                          for (int angle = 180; angle >= 0; angle -= 1) {
                                            myServo.write(angle);
                                            delay(15);
                                          }
                                          delay(1000); // Wait for a second
                                        }
                                        
                                
                            

    FILES

    Here you can download all the files that I have made for the following assignment:

  • LED BLINK. INO
  • BUTTON LED. INO
  • SEQUENCE. INO
  • ULTRASOUND. INO
  • MOTION SENSOR. INO
  • SERVO MOVE. INO
  • LEARNED

  • This week I learned how to program basic components such as LEDS and know how to use the ARDUINO.IDE, its language is very easy and understand how component programming works.
  • I learned that it is important to know the pin numbers and each characteristic that microcontrollers present since it is important when programming with inputs or outputs.
  • I learned how to program INPUTS and OUTPUTS from the QUENTORRES, likewise, I understood that this board does not have the characteristic of programming OLED or SCREENS but in the next few weeks we will be able to do it.
  • TO TAKE INTO ACCOUNT

  • We have to be careful with soldering our components on our board as they can burn our microcontroller. That's why I recommend checking everything before connecting the microcontroller to the PC.
  • The RESET button is not to be pressed all the time on the XIAO RP2040 since it does not have the concept that what has been programmed is going to be deleted. We have to understand that it is only important to RESET when we want to change programming languages.
  • We have to understand that the QUENTORRES cannot yet program outputs such as OLED screens since we need pins 6 and 7 to program it. So, we have to be careful with some outputs that we place on the board.
  • LINKS