6. Embedded Programming
assignment
- individual assignment: 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
- group assignment: browse through the data sheet for your microcontroller compare the performance and development workflows for other architectures
group assigment:
Link to group assignment page
The group assignment page can be found on the Energylab 2024 website here
it is also embedded directly in the webpage below.
Below is the data sheet comparison I made and chose to make use of to select the microcontroller
Individual assigment:
Here is the datasheet and other specifications of the microcontroller RP2040 i’m using :
Item | Description |
---|---|
CPU | Dual-core ARM Cortex M0+ processor up to 133MHz |
Flash | Memory 2MB |
SRAM | 264KB |
Flash | Memory 2MB |
SRAM | 264KB |
Digital I/O | Pins 11 |
Analog I/O | Pins 4 |
PWM | Pins 11 |
I2C interface | 1 |
SPI interface | 1 |
UART interface | 1 |
Power supply and downloading interface | Type-C |
Power | 3.3V/5V DC |
Dimensions | 20×17.5×3.5mm |
CAUTION
“For general I/O pins: Working voltage of MCU is 3.3V . Voltage input connected to general I/O pins may cause chip damage if it’ higher than 3.3V .”
“For power supply pins: The built-in DC-DC converter circuit able to change 5V voltage into 3.3V allows to power the device with a 5V supply via VIN-PIN and 5V-PIN.”
“XIAO RP2040 currently only supports battery power supply and cannot connect to Type-C while a battery is connected, as it may pose a safety risk.”
“Please pay attention to use, do not lift the shield cover.”
Programming
IDE Configuration
For more information on the RP2040 go on the official seed studio website It will give you everything you need to learn how to use your xiao
So, in my program to interact with the microcontroller development board, I have used the button as my local input device and the LED as an output device.
- 1) First: open Arduino IDE software
- 2) Second: Add the Seeed Studio XIAO RP2040 board package to your Arduino IDE Go to File > Preferences and fill in the additional board manager URLs with the URL below: https://github.com/earlephilhower/arduinopico/releases/download/global/package_rp2040_index.json
- 3) Third: Go to the Board Manager by clicking on the board icon at the left side of the IDE and then enter the keyword RP2040 in the search bar. Select the latest version of Raspberry Pi Pico/RP2040 and install it.
- 4) forth: go to program and upload code for RP2040 by selecting the RP2040 board in Tools -> Boards -> Raspberry PI Pico/ RP2040 -> Seeed XIAO RP2040
Below is the program in detail.
const int LED = 26;
const int Button = 27;
boolean oldbuttonState = LOW;
boolean newbuttonState = LOW;
boolean LEDstatus = LOW;
void setup() {
pinMode(LED, OUTPUT);
pinMode(Button, INPUT_PULLUP);
digitalWrite(LED, LOW);
}
void loop() {
newbuttonState = digitalRead(Button);
if (newbuttonState != oldbuttonState) {
if (newbuttonState == HIGH) {
if (LEDstatus == LOW) {
digitalWrite(LED, HIGH);
LEDstatus = HIGH;
}
else {
digitalWrite(LED, LOW);
LEDstatus = LOW;
}
}
oldbuttonState = newbuttonState;
}
}
Here is the video of testing
Last update:
November 21, 2024