Week 4
Embedded Programming
The group assignment involves demonstrating and comparing the toolchains and development workflows for different embedded architectures. Individually, you are required to review the datasheet of your microcontroller, write a program for it, and simulate its operation. The program should enable interaction with local input and/or output devices and facilitate communication through remote wired or wireless connections. For extra credit, you can test the program on a development board and explore different programming languages or development environments.
Group Assignments


This week's group assignment involved exploring of multiple micro controllers and Multiple tool chains so I explored Rasp berry pi for this I flashed pi os in one raspberry pi and and explored the basic working and after that I made a simple program in raspberry pi and tested it using the GPIO in it and others have tested the different work flows for different tool chains.
For more info visit our group assignment page.
Link : week04 Group Assignment
For this week i was planing the basics of embedded programming for this i used wokwi and pico for learning the basics of embedded programming and also used arduino uno for learning the basics of embedded programming and i have tested some basic programs.
WOKWI
Wokwi is a online simulation platform used for simulating and testing of programs in a micro controller. Micro controllers like ESP32, Raspberry Pi Pico etc. are available for for testing and simulations. It is a good platform for beginners for testing for more advanced simulations its better to use a more advanced simulator.
PICO
The Raspberry Pi Pico is a small microcontroller board by the Raspberry Pi . It uses a RP2040 microcontroller chip. It has a dual-core ARM Cortex-M0+ processor it can run at speeds up to 133 MHz, 264 KB of SRAM, and 2 MB of onboard flash memory for storing your programs. IT also have the Programmable I/O (PIO) subsystem, The PIO subsystem offloads work from the main CPU, freeing it up for other tasks.
Pico is compact and can be easily used for DIY projects, It has 26 GPIO pins and it also supports UART, SPI, I2C, and PWM, It also have a 12 bit analog-to-digital converter (ADC),a built-in temperature sensor, and low-power sleep modes to save energy
Image source : https://projects.raspberrypi.org/en/projects/getting-started-with-the-pico
You can program it in multiple languages, including MicroPython, C/C++, and CircuitPython, and it connects to your computer via a Micro-USB port for easy programming.
To learn more : Getting started with Raspberry Pi Pico | Micropython | Coding projects for kids and teens
RP2040 Datasheet Overview and Architecture
Brief on the RP2040 Datasheet
The RP2040 is a microcontroller developed by Raspberry Pi. The datasheet provides technical documentation that includes the chip’s specifications, architecture, and programming model.
- Dual-core Arm Cortex-M0+ running at up to 133MHz
- 264KB SRAM
- No built-in flash; uses external QSPI Flash
- 30 GPIO pins with versatile functions (UART, SPI, I2C, PWM, etc.)
- 2 PIO (Programmable I/O) blocks for custom peripheral implementations
- DMA support for memory/peripheral transfers
- USB 1.1 host/device support
- Built-in timers and watchdog
Using the Datasheet to Understand the Chip
The datasheet is crucial for exploring and understanding the RP2040’s capabilities:
- Pin configuration: Learn how to map and use each GPIO pin
- Memory mapping and registers: Understand how peripherals are accessed and controlled
- Peripheral usage: Study how to configure and operate UART, I2C, SPI, and PIO
- Electrical specifications: Essential for safe hardware integration
- Software model: Get insight into interrupts, vector tables, and dual-core programming
RP2040 Architecture Overview
The RP2040 is based on a dual-core Cortex-M0+ architecture with custom peripheral and bus architecture.
Main Architectural Features
- Dual-core Cortex-M0+: Efficient, low-power cores sharing memory and peripherals
- Bus fabric: Multi-layer bus enabling parallel memory and peripheral access
- PIO (Programmable I/O): User-programmable state machines for custom protocols
- Clocks: Configurable internal PLLs for precise clock management
- DMA controller: Offloads data transfers from the CPU
- Timers and watchdog: Includes a real-time clock and safety watchdog
- USB and GPIO: Full-speed USB and re-mappable GPIO functions
AI Prompt : Give a brief overview of the RP2040 & Its architecture.
Technical Specifications
- Chip: RP2040 (Dual-core ARM Cortex-M0+)

Documentation Link : Pico-series Microcontrollers - Raspberry Pi Documentation
Clock Speed
- Max Speed: 133 MHz
Memory
- Flash Memory: 2MB
- SRAM: 264KB
GPIO and Analog Pins
- Total GPIO Pins: 26
- Analog Input Pins: 3
Communication Protocols
- UART: 2
- I2C: 2
- SPI: 2
- I2S: Yes
- PWM: Available on all GPIO pins
- PIO: 2 Programmable I/O
Analog-to-Digital Converter (ADC)
- 12-bit ADC (3 channels and 1 internal temperature sensor)
Electricals
Voltage Requirements
- Microcontroller Operating Voltage: 1.8V to 3.3V
- Board Power Supply: 1.8V to 5.5V (via VSYS)
- USB Power: 5V
GPIO Electrical Characteristics
- Output Voltage:
- High: 3.3V
- Low: 0V
- Maximum GPIO Sink/Source Current:
- Per Pin: 12mA max
- Total GPIO Current: 50mA max
- Input Voltage Tolerance:
- Maximum GPIO Input Voltage: 3.3V
- Higher voltages require a voltage divider or level shifter
Documentation Link : Pico-series Microcontrollers - Raspberry Pi Documentation
ChatGPT Prompt : What are the electrical specifications for the Raspberry Pi Pico?
PICO Wokwi Simulation
- From the top left corner click on the profile photo and open the drop down window and then to create a new simulation select “My Projects”
- Then from the new window click on the new project button, then scroll down and select the board
- In my case I am using a Raspberry pi pico and from the window select the language being used, Here i am using Micro Python
- Also there is an VS Code Extension for wokwi For more Info : Getting Started with Wokwi for VS Code | Wokwi Docs
- This is the interface that opens, here in the left side the top green button stars the simulation, The blue plus button is used for adding peripherals into the simulation
“Hello, Raspberry Pi Pico” Simulation Using C++
- This is the first program I wrote, this is to print a string in a loop.
- For this project no external peripherals are needed.
void setup() { // put your setup code here, to run once.
Serial1.begin(115200);//This command is used to initiate communication with serial monitor.
}
void loop() {
// put your main code here, to run repeatedly
Serial1.println("Hello, Raspberry Pi Pico!");
//This commands used to print the output in serial monitor,
//The "Println" used to pint in the next line.
delay(2000); // this speeds up the simulation
}
- This is the output i received
Blinking Internal LED using Micro Python
- The next program I made was a simple blink internal led and for this I referred the examples from Wakwi. Link : https://wokwi.com/pi-pico
import time #This to import time library
import machine #This is to import the machine library
led machine.Pin (25,machine.Pin.OUT) #This is to define the pin
Count = 0
while True: //This is to create a loop
print(Count)
time.sleep(1)
led.value(1) #This is to make the LED pin state to high
time.sleep(2) #This to add a delay
led.value(0) # This is to make the LED pin state to LOW
time.sleep(2)
- This the final output
Blinking External LED using Micro Python
- Here I simulated the blinking of an LED connected to Pin 27
- Here I have added an external resister depending on the calculate value. Link : https://ohmslawcalculator.com/led-resistor-calculator
import time
import machine
led machine.Pin(27,machine.Pin.OUT)
Count = 0
while True:
print(Count) //This is to print the count
time.sleep(1) //This is to add a delay
led.value(1) //This is to make the LED pin state to high
time.sleep(2)
led.value(0) //This is to make the LED pin state to low
time.sleep(2)
- This is the Final Result
Neo pixel LED using Micro Python
The NeoPixel LEDs are RGB LED lights with a built driver IC that makes these lights addressable and programmable.
- Here I have made a simple program for running a neo pixel LED
- I have refereed a existing example for making this program Link : WokwiMakesRaspberry Pi Pico on Wokwi - Online ESP32, STM32, Arduino Si…
import time
from neopixel import Neopixel # Import the Neopixel library
# Initialize the Neopixel object
# Arguments: number of LEDs, state (0 = normal), pin number (6), and color order
pixels = Neopixel(17, 0, 6, "GRB")
# Define a list of RGB color tuples for the LEDs
colors = [
(0xb6, 0xe4, 0x30), # Yellow-ish
(0x42, 0xd1, 0xee), # Cyan-blue
(0x00, 0x00, 0xff), # Blue
(0xff, 0x00, 0x00), # Red
(0x00, 0xff, 0x00), # Green
]
pixel_index = 0 # Tracks the current pixel to update
color_index = 0 # Tracks the current color in the colors list
while True:
# Set the current pixel to the current color
pixels.set_pixel(pixel_index, colors[color_index])
pixels.show() # Update the LED strip with new color data
# Move to the next pixel
pixel_index += 1
# If we reach the end of the strip, reset and change to next color
if pixel_index == 17:
pixel_index = 0
color_index = (color_index + 1) % len(colors) # Loop through colors cyclically
time.sleep(0.1) # Wait for 100ms before updating the next pixel
- This is the Final Result
Neo pixel LED Color control using Micro Python
- First step was to design the circuit.
- From the top left section click the plus button to add new component
- Depending upon the component make the necessary connections.
- Here i gave a external pull_Up resister.and connected the
- some micro controllers have a pull up resister inbuilt.
- Here I made a program for neo pixel LED in which when a switch is triggered the color changes.
Pull-Up Resistor
What it does: It pulls the wire up to a high voltage (1) when nothing else is connected.
Pull-Down Resistor
What it does: It pulls the wire down to a low voltage (0) when nothing else is connected.

import time
from neopixel import Neopixel
from machine import Pin
# Initialize Neopixel object
# Parameters: number of LEDs = 17, state = 0 (default), pin = 6, color order = GRB
pixels = Neopixel(17, 0, 6, "GRB")
# Define the input pin for the switch with pull-down resistor
Switch = Pin(26, Pin.IN, Pin.PULL_DOWN)
value = 0 # Initial value of the switch input
# Define a list of RGB color tuples for the LED strip
colors = [
(0xb6, 0xe4, 0x30), # Yellow-like
(0x42, 0xd1, 0xe0), # Cyan
(0xff, 0x00, 0x00), # Red
(0x00, 0xff, 0x00), # Green
]
pixel_index = 0 # Tracks current LED to update
color_index = 0 # Tracks current color from the list
# Main loop
while True:
# Set the color of the current pixel
pixels.set_pixel(pixel_index, colors[color_index])
pixels.show() # Update the LEDs
pixel_index += 1 # Move to the next pixel
# Read the state of the switch
value = Switch.value()
print("Switch:", value) # Print the switch state to serial for debugging
time.sleep(0.2) # Short delay between updates
# Reset the pixel index if it reaches the end of the strip
if pixel_index == 17:
pixel_index = 0
time.sleep(0.1)
# If the switch is pressed, cycle to the next color
if value == 1:
color_index = (color_index + 1) % len(colors) # Loop through available colors
- This is the final result
Observations
From my observations using micro python is more efficient compared to c++ in Wokwi, I think it is because Micro python executes the program line by line and c++ is taking a lot of time for simulating and it was failing multiple times .
Arduino IDE
The Arduino software (IDE) is an open source software, which is used to programme the Arduino boards, and is an integrated development environment, developed by arduino.cc. Allow to write and upload code to Arduino boards.I had already used Arduino IDE so i hade it already installed
For setting up follow this link : https://www.tutorialspoint.com/arduino/arduino_installation.htm
Arduino Uno
Arduino UNO is a microcontroller board based on the ATmega328P. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery.
Image source : Imagen de la placa Arduino Uno R3. Fuente: Proyecto Arduino.... | Download Scientific Diagram
Image source : Arduino Uno Pinout Guide
Technical Specifications
Micro controller Chip
- Chip: ATmega328P

Documentation Link : raspberrypi.com/documentation/microcontrollers/pico-series.html
Clock Speed
- Speed: 16 MHz
Memory
- Flash Memory: 32KB
- SRAM: 2KB
- EEPROM: 1KB
GPIO and Analog Pins
- Total GPIO Pins: 14
- PWM Pins: 6 (D3, D5, D6, D9, D10, D11)
- Analog Input Pins: 6 (A0 - A5)
Communication Protocols
- UART: 1 (Serial communication on pins 0 & 1)
- I2C: 1 (SDA on A4, SCL on A5)
- SPI: 1 (MISO - D12, MOSI - D11, SCK - D13, SS - D10)
Analog-to-Digital Converter (ADC)
- Yes, 10-bit ADC (6 channels, 0-1023 range)
Electrical Specifications
Voltage Requirements
- Operating Voltage: 5V
- Input Voltage : 7-12V
- Input Voltage : 6-20V
Logic Voltage
- 5V logic level
GPIO Electrical Characteristics
- Output Voltage:
- High: 5V
- Low: 0V
- Maximum GPIO Sink/Source Current:
- Per Pin: 40mA max
- Total Max Current for all I/O Pins: 200mA
- 3.3V Pin Max Current Output: 50mA
- Input Voltage Tolerance:
- Digital Pins: 0V to 5V
- Analog Pins: 0V to 5V
Documentation Link : docs.arduino.cc/hardware/uno-rev3/
ChatGPT Prompt : What are the electrical specifications for the Arduino Uno?
Blink LED Using Arduino Uno
- Here I have used c++ to make a simple LED blinking program
- Here i have used a resister depended on the calculated value of resistance Link : https://ohmslawcalculator.com/led-resistor-calculator
void setup() { pinMode(A1, OUTPUT);//Defining A1 pin as output } void loop(){ digitalWrite(A1, HIGH); //Making the pin High delay(1000); //Giving a delay of 1 second digitalWrite(A1, LOW); //Making the pin LOW delay(1000); }
- This is the circuit diagram
- This is the Final output
LED Brightness control Using Potentiometer
- Here I have used a potentiometer to control the brightness of the brightness of an led
- While testing this i learned about PWM signal and also understood that there are specific pins in Uno that can give a PWM signal which is represented by “~”
#define LED 11 //Here the pin's are defined #define Potentiometer A0 void setup() { Serial.begin(9600); pinMode (LED, OUTPUT); //here Pin is defined as out put } void loop() { int Brightness = analogRead(Potentiometer); //Reading analog the value from potentiometer analogWrite(LED, Brightness); //Out puting analog value to the LED Serial.println(Brightness); //print the value of brightness in serial monitor }
- This is the circuit
- Final output
Servo Angle Control Using potentiometer
- The next thing i tried out was controlling the angle of servo using potentiometer
#define Servo 11 void setup() { Serial.begin(9600); //This command is used to initiate communication with serial monitor pinMode(Servo, OUTPUT); } void loop() { int Input = analogRead(A1); //Reading analog the value from potentiometer int Angle = map(Input,0,1023,0,360); // Here map is used connect the voltage pwn level to angle Serial.println(Angle); //print the value of angle in serial monitor analogWrite(Servo, Angle); //Out puting analog value to the Servo }
- This is the circuit
- This is the final output
What is debugging
Debugging is the process of finding and fixing problems in a program. It involves a step by step process of figuring out what’s going wrong, and then fix it so everything works Properly.Serial monitor, serial plotter and devices like oscilloscope are used for debugging
Serial Monitor
"The serial monitor is a tool used for debugging. It can be used for showing outputs and giving inputs into a program while it is running. It is commonly used in embedded systems development with microcontrollers.
C++
In Arduino (C++), the Serial.print() and Serial.println() functions are used to send data to the serial monitor.
MicroPython
In MicroPython, the print() function is used to send data to the serial monitor. Additionally, you can use the uart module for more advanced serial communication.
Conclusion
I explored programming on the Raspberry Pi and worked with the Pico and Seeed Studio boards using MicroPython. I also experimented with the Arduino Uno in the Arduino IDE and tried out the Thonny IDE. This experience gave me a better understanding of different development environments and programming workflows for embedded systems.