Week 4 Embedded Programming
1️⃣ Initial Observations – Understanding Embedded Systems in the Lab
At the beginning of the week, I observed different embedded system projects in the lab:
A smoke sensor system that detects gas/smoke levels and triggers alerts.
A line-following robot that recognizes a black line on the floor using sensors and adjusts its movement accordingly.
And most interestingly, I was inspired by Thing, the disembodied hand from Wednesday.
Seeing these systems helped me understand one important thing:
Embedded systems are not just circuits. They are decision-making systems.
Each of them followed a pattern:
Sense something
Process it
Act accordingly
That became the foundation of my own experiment.
2️⃣ Concept – Building a Reactive Walking Robot
Inspired by the hand from Wednesday, I decided to attempt a small robotic creature that:
Uses servo motors as legs
Uses an ultrasonic sensor as input
Moves forward or backward depending on distance
Behaves like a reactive system
Hardware Used
Arduino Uno
4 Servo motors
Ultrasonic sensor (HC-SR04)
External power supply for servos
Arduino IDE for coding
3️⃣ Architecture of the Robot
The idea was simple:
Input:
Ultrasonic sensor measures distance.
Processing:
Arduino checks distance condition.
Output:
If object is close → move forward.
If object is far → move backward.
The structure of logic was:
Read distance → Compare with threshold → Call movement function
I first tested:
Single servo
Then 4 servos together
Then created forward and backward movement functions
Finally integrated ultrasonic input

I learned the importance of:
Common ground between external power and Arduino
Testing movement before adding sensing
Structuring code into functions
This phase taught me about sequencing and debugging physical motion.
4️⃣ Going Deeper – Understanding the Microcontroller Itself
After working with Arduino, I became curious:

What is actually inside Arduino?
Arduino Uno uses a chip called ATmega328P. But to simplify and understand further, I explored:
ATtiny85
This is a small 8-pin microcontroller.
5️⃣ Understanding Core Concepts 🔹 What is a Bootloader?
A bootloader is a small program that:
Runs before your main program
Allows code to be uploaded through a programmer
Sets configuration bits (clock speed, internal settings)
For ATtiny85:

Burning bootloader mainly sets internal clock (8 MHz).
It does NOT install a USB system like Arduino.
🔹 What is a Library?
In Arduino IDE, when we write:
digitalWrite(0, HIGH);
That is not directly understood by the chip.
The IDE:
Compiles code
Converts it into machine instructions
Uploads binary to microcontroller
The chip runs pure machine code. It does not “use Arduino library” after upload.
🔹 PIO – General Purpose Input Output
PIO (GPIO) are pins that can act as:
INPUT (read button/sensor)
OUTPUT (drive LED/servo)
These pins are programmable.
They are the connection between: Software logic ↔ Physical world.
6️⃣ PCB & Component Understanding
This week I also started observing hardware more carefully.
🔹 SMD vs Through-Hole
Through-hole components have long leads that go through the board.
SMD (Surface Mount Devices) sit directly on the surface.
SMD:
Smaller
Used in compact circuits
Requires precise soldering
Through-hole:
Easier for beginners
More mechanical strength
🔹 LED Polarity
In LEDs:
Longer leg = Positive (Anode)
Shorter leg = Negative (Cathode)
Inside the LED, the larger internal plate usually indicates the negative side.
If connected wrong, LED will not glow.
🔹 Diode (D)
A diode allows current to flow in only one direction.
Symbol: D
Used for:
Protection
Rectification
Preventing reverse polarity damage
🔹 PCB Orientation & Markings
On boards, I noticed:
Small green solder mask layer
Tiny white labels
Junction pads
Component outlines
Pin number indicators
Polarity marks
Correct orientation matters.
If you flip IC direction, it won’t work.
7️⃣ Debugging Using CRO
CRO = Cathode Ray Oscilloscope.
It is used to:
Observe voltage over time
See pulse signals
Check PWM waveforms
Debug signal timing
For example:
Servo control signal can be visualized.
PWM signals can be seen clearly.
If signal is unstable, CRO shows waveform distortion.
This helped me understand that:
Embedded systems are electrical signals over time — not just code.
8️⃣ Key Learnings This Week
Embedded systems follow a pattern:
Input → Process → Output
Mechanical stability is as important as code.
Microcontrollers do not “understand Arduino” — they execute machine code.
Burning bootloader configures internal hardware settings.
GPIO pins are the bridge between software and hardware.
Hardware polarity and orientation are critical.
Debugging requires observing signals, not just reading code.
9️⃣ Reflection
This week shifted my understanding from:
“Using Arduino”
to
“Understanding how microcontrollers actually work.”
I moved from:
High-level robotics
To chip-level configuration
To signal-level debugging
It made embedded systems feel less like a black box and more like a structured architecture of:
Electricity → Timing → Logic → Movement