Group Assignment

demonstrate and compare the toolchains and development workflows for alternative embedded architectures

Please for group assignment details visit Anderson Zelarayan Web Page.

Individual Assignment

Write a program for a microcontroller development board to interact (with local input &/or output devices) and communicate (with remote wired or wireless devices)

I worked with the board I developed in week 4th and use Module XIAO RP2040.

PCB Programing

First I wanted to explore more programing options using Arduino IDE. You can download the program from here

LED Blinking

  1. We need first to prepare the Arduino IDE to work with XIAO RP2040
  2. We need to add Seeed Studio XIAO RP2040 board package to Arduino IDE's preferences (See photo).
  3. Like recomended on Seeed Studio and install earlephilhower package.

  4. We need to go to Board Manager and install Raspberry Pi Pico/RP2040.
  5. Then, we need to click on Tools, board board manager. In that way Arduino IDE will recognise the XIAO RP2040

  6. We need to wrote a small program in Arduino to test the board. I decided to develop a simple program to turn LED on and off

  7. 
    // Blink
    // Define pin numbers
    const int LedPin =  D0;  // the number of the LED pin
    	
    // the setup function runs once when you press reset or power the board
    void setup() {
      // initialize digital pin LedPin as an output.
      pinMode(LedPin, OUTPUT);
    }
    	
    // the loop function runs over and over again forever
    void loop() {
      digitalWrite(LedPin, HIGH);  // turn the LED on (HIGH is the voltage level)
      delay(100);                      // wait for a second
      digitalWrite(LedPin, LOW);   // turn the LED off by making the voltage LOW
      delay(100);                      // wait for a second
    }
    
    

  8. The following video shows how the led goes on and off

LED Activated by a Button

  • We need to wrote a small program in Arduino to test the board. I decided to develop a simple program to turn LED on and off, but using push buttom.Similar to what I used for week 4th
  • But I modified it, so the LED will be on when I push de button

  • 
    	// Define pin numbers
    	const int buttonPin = D1; // the number of the pushbutton pin
    	const int ledPin =  D0;  // the number of the LED pin
    	
    	// Variables will change:
    	int buttonState = 0; // variable for reading the pushbutton status
    	
    	void setup() {
    	  // Initialize the LED pin as an output:
    	  pinMode(ledPin, OUTPUT);
    	  // Initialize the pushbutton pin as an input with internal pull-up resistor:
    	  pinMode(buttonPin, INPUT_PULLUP);
    	}
    	
    	void loop() {
    	  // Read the state of the pushbutton value:
    	  buttonState = digitalRead(buttonPin);
    	
    	  // Check if the pushbutton is pressed.
    	  // If it is, the buttonState is LOW:
    	  if (buttonState == LOW) {
    		// Turn LED on:
    		digitalWrite(ledPin, LOW);
    	  } else {
    		// Turn LED off:
    		digitalWrite(ledPin, HIGH);
    	  }
    	}
    
    
  • At the begining the "const int buttonPin = D1" assign the number of the pushbutton pin and the "const int ledPin = D0" define the number of the LED pin. This assign correspond to the following Pinout


  • The "void setup" is a function that contains the initialization of the two components that I want to control (input=Push Button and output=LED)
  • "pin mode", will configure the pin DO to behave either as an ouput (LED) and D1 as an input (Push Buttom)
  • "void loop" allows to repeat your code over and over again, that is why we need to add here the "buttonState = digitalRead(buttonPin)" (input D1)
  • Then, we need will set a HIGH or a LOW value to output digital pin, in this case pin DO (LED Connection). Because the pin has been configured as an OUTPUT with pinMode(),its voltage was set to receiving 5V - 3.3V, being in HIGH mode (turn LED on) when the buttom is pushed (buttonState == HIGH)
  • And it will receive 0V (ground) being in LOW mode (turn LED off) when the buttom is not pushed (buttonState == HIGH)
  • Then, we just need to tried if the program runs, like shown in the folowing video
  • run the program and check for LED lightining like shown in the video below.The LED goes on when pushing the buttom

  • LED Activated by a Button While sending information through Serial Monitor

  • I again modified the previos code so we can observe the report of Input state (Button) in the Serial Monitor that Arduino IDE provides
  • Below you can get acess to code I followed

  • 
    	// Define pin numbers
    	const int buttonPin = D1; // the number of the pushbutton pin
    	const int ledPin =  D0;  // the number of the LED pin
    	
    	// Variables will change:
    	int buttonState = 0; // variable for reading the pushbutton status
    	
    	void setup() {
    		Serial.begin(9600);
    		// Initialize the LED pin as an output:
    	  pinMode(ledPin, OUTPUT);
    	  // Initialize the pushbutton pin as an input with internal pull-up resistor:
    	  pinMode(buttonPin, INPUT_PULLUP);
    	}
    	
    	void loop() {
    	  // Read the state of the pushbutton value:
    	  buttonState = digitalRead(buttonPin);
    	  Serial.print("button state: ");
      	  Serial.println (buttonState);
    
    	
    	  // Check if the pushbutton is pressed.
    	  // If it is, the buttonState is LOW:
    	  if (buttonState == LOW) {
    		// Turn LED on:
    		digitalWrite(ledPin, LOW);
    	  } else {
    		// Turn LED off:
    		digitalWrite(ledPin, HIGH);
    	  }
    	}
    
    
  • I included Serial.begin(9600); to pass the value 9600 as speed parameter. This tells the Board to get ready to exchange messages with the Serial Monitor at a data rate of 9600 bits per second. That's 9600 binary ones or zeros per second, also known baud rate.
  • Then Serial.print("button state: "); Prints data to the serial port as human-readable ASCII text. In this case when I physically interaction with the input (bUtton), will report its state on the serial monitor
  • Finally, Serial.println; will allows that every time the button state is reported in the serial monitor, it will be on a next line (like pressing enter every time)
  • run the program and check for LED lightining and the report on the serial monitor like shown in the video below.The LED goes on when pushing the buttom

  • You can get access to the Arduino code here.