Skip to content

Search

Search courses, labs, notes, tools…

Guided lab · ECE 1

Microcontroller: drive a transistor and LED, read a sensor divider

A Raspberry Pi Pico runs real MicroPython on the circuit bench: its ADC reads a voltage divider on the breadboard and a GPIO pin switches an LED through an NPN transistor

Time
45 min
Bench
Circuit bench

Free. The lab opens after Google sign-in, which also keeps your progress.

Screenshot of the "Microcontroller: drive a transistor and LED, read a sensor divider" virtual lab running on the Circuit bench, wired and measuring

What you do in this lab

You will connect a microcontroller to real circuit nodes. A 10 kΩ resistor and a potentiometer (a rotary position sensor) form a voltage divider; the Pico's 12-bit ADC reads it. When the voltage is below 1.20 V the program sets GP15 high, and a 2N3904 transistor switches a 13.5 mA LED that a 3.3 V pin could not drive by itself. Every voltage and current comes from ngspice, and the program is real MicroPython on an emulated RP2040.

Objectives

  • Calculate the output of a voltage divider and the ADC code it gives: $code = V/V_{ref} \cdot (2^{12}-1)$.
  • Explain why a GPIO pin drives a transistor instead of the LED directly (pin current, supply voltage).
  • Design the base resistor of a saturated NPN switch and check $V_{CE(sat)}$, $I_B$ and $I_C$.
  • Follow a closed loop: sensor → ADC → program → GPIO → transistor → LED.

Inside the lab

Step-by-step instructions with wiring checks, the readings you should get, questions with model answers and a short quiz. Sign in to open it.

Unofficial, free student project. Not affiliated with Emona Instruments or with any university. Emona and ETT-101 are trademarks of their owner.