1 of 33

Intro to Embedded

2025

2 of 33

Overview

Part 1 - Introduction

  • What is a microcontroller?
  • Setting up our development environment
  • Running our first program

Part 2 - Hardware Basics

  • LEDs
  • Resistors
  • Using a Breadboard
  • PWM

Part 3 - Sensors

  • Button
  • Potentiometer

Part 4 - Making some stuff!

Next week…

  • Wifi and bluetooth
  • More interesting sensors
  • Interrupts
  • MQTT & other protocols
  • Harder challenges!

3 of 33

Requirements

  • Download VSCode

  • Download the Platformio Extension

4 of 33

What is a Microcontroller?

  • Basically a tiny computer on a single circuit

  • ESP32, STM32, Atmega328P

  • GPIO pins interact with other hardware

5 of 33

The ESP32

  • Wifi & Bluetooth
  • Low power consumption
  • I/O peripherals (USART, ADC etc)
  • Lots of GPIO pins

6 of 33

The ESP32

We must know pin numbers to access them in code.

Search up “pinout diagram” for

whichever microcontroller you use.

7 of 33

Creating a New Project

8 of 33

Project Structure

9 of 33

Serial Communication

Baud rate: The speed of communication (bits per second) between the microcontroller and computer

10 of 33

Upload to ESP32

11 of 33

Accessing GPIO pins

12 of 33

Digital Outputs

  • We can turn pins on or off through code
  • By changing the voltage running through pins, we affect the hardware connected to it

In logic In the real world

ON HIGH TRUE 1 3.3 or 5V Vcc

OFF LOW FALSE 0 0V GND

13 of 33

Light Emitting Diodes (LEDs)

Diode: A one-way valve for electric current.

This means you must take care to wire LEDs

in the correct direction

14 of 33

Light Emitting Diodes (LEDs)

15 of 33

Resistors

Control voltage levels and prevent components from burning out

16 of 33

Breadboard

17 of 33

Let’s start wiring!!!

18 of 33

Let’s start wiring!!!

Try to make the following circuit

use a resistor between 200 - 5000 Ohms

19 of 33

Wiring

What happens if we connect it to pin 2?

20 of 33

How can we control LED brightness?

21 of 33

Pulse Width Modulation (PWM)

22 of 33

Pulse Width Modulation (PWM)

23 of 33

Push Button

When pressed, the button closes

the circuit, allowing current to flow through

24 of 33

Push Button

25 of 33

Reading a Pin

‘reading’ will be either 0 or 1

26 of 33

Push Button

What is the state of pin 2 when button is pressed?

What about not pressed?

27 of 33

Pull Up and Pull Down

When setting a pin mode to input, we must specify whether it should be pulled to GND or 5V by default

INPUT_PULLUP => 5V by default

INPUT_PULLDOWN => GND by default

28 of 33

Push Button Example

29 of 33

Potentiometer

Provides variable resistance,

depending on where it is turned

30 of 33

Potentiometer

31 of 33

Choose Your Next Quest

32 of 33

Next Workshop

  • Ultrasonic Sensors
  • Servo Motors
  • RGB LEDs
  • Wifi & Bluetooth
  • More quests!

📍 Where: CB11.05.400 (iHub)

📆 When: Thursday, 11th September

⏰ Time: 6:00 pm - 8:00 pm

33 of 33

Thank You