Source: https://mokxi.com/parts/phototransistor
Updated: 2026-11-16

Part

# Phototransistor

The Arduino Starter Kit light sensor: a collector current that follows the light, read across a resistor. Drag the slider.

See every part

- 2 pins
- 1 setting
- In 1 project

Drawn live by the editor's own code, at the size you see it.

At a glance

## The Phototransistor in brief

What it is, and every setting the properties panel gives it.

The phototransistor is a two lead NPN in a clear 5 mm package, the light sensor in the Arduino Starter Kit, which carries six of them for the Color Mixing Lamp and the Light Theremin. There is no base lead: light through the lens makes a photocurrent where the base would be, and the transistor’s gain turns it into a collector current several hundred times larger. The pins are C, the collector, to the supply side, and E, the emitter, to the ground side, usually through the resistor you read across. The sensitivity property is the collector current per lux in microamps with 5 V across the part, 2 by default. A slider is the light in lux, 0 to 5000.

Family

Sensors

Pins

2

sensitivity

2

Pins

## 2 pins

Named as the editor names them, so a wire lands where you expect it.

Pin

What it does

C

Collector: to the supply side.

E

Emitter: to the ground side, usually through the resistor you read across.

How to use it

## How to read a phototransistor with an Arduino and play a theremin

The Starter Kit wiring: the collector C to 5 V, the emitter E to analog pin A0, and a 10 k resistor from that pin to ground. The pin reads the collector current times 10 k, so it is 0 in the dark and near 1023 in a lit room. A piezo on pin 8 has its other leg on ground.

The sketch maps the reading from 0 to 1023 onto 120 to 1500 Hz and plays it with tone(), so the pitch follows the light. Drag the light slider in the part’s window, 0 to 5000 lux, and listen. A phototransistor is a current that follows the light, so across 10 k it reads in proportion until the resistor runs out of voltage and it saturates a little short of 5 V.

Part pin

Goes to

C

5 V

E

A0, and a 10 k resistor to ground

Piezo +

Pin 8

Piezo -

GND

Click to open it in the editor

This is the simulator itself, running here. Click anything to open it in the editor.

Open this project in the editor Read the full tutorial

Light sets the pitch

Common errors

## Common Phototransistor errors and fixes

What goes wrong

The fix

The reading is stuck near the top in a bright room.

The transistor has saturated. In a bright room the 10 k divider sits near the top, so use a smaller resistor to read bright light.

The reading falls when the light rises.

Check the wiring: collector to 5 V, emitter to the pin with the resistor to ground. Swapped, the reading is inverted.

It is used like an LDR with a divider.

An LDR is a resistor that follows the light, a phototransistor is a current that follows it. Read across a resistor on the emitter.

Questions

## Questions and answers

### What are the phototransistor’s pins?

C, the collector, to the supply side, and E, the emitter, to the ground side. There is no base lead.

### What is the difference between a phototransistor and an LDR?

An LDR is a resistor whose value follows the light. A phototransistor is a current that follows the light, a collector current several hundred times the photocurrent.

### What is the sensitivity of the model?

2 microamps of collector current per lux with 5 V across the part, set by the sensitivity property.

How it is modeled

## What is true about the Phototransistor, here

In its help article’s own words: what the simulation gets right, and where it stops.

### Modeled

A current, not a resistance. In the active region the collector current is
sensitivity x lux, nearly independent of the voltage across the part: 20 lux
is 40 uA, which is 0.4 V across 10 k.

Saturation. It is Ebers-Moll with the base current set by the light, so as
the resistor's drop leaves less than a few tenths of a volt across the part the
current falls off, and the reading stops near 4.8 V rather than reaching 5 V.

Dark current. 10 nA in the dark, a tenth of a millivolt on 10 k.

Backwards it barely works. Reversed, it runs on the reverse gain, a hundredth
of the forward one, so a phototransistor put in the wrong way around reads almost
nothing.

The Early effect. The current climbs a little with the voltage across the
part, about a tenth from 0 to 5 V, as on a curve tracer.

The numbers are assumptions in the range the visible-light phototransistors'
sheets print: tens of microamps at 20 lux, a dark current of tens of nanoamps at
most, a gain of several hundred. Real parts vary by a factor of two or more from
one to the next.

### Not modeled

Color: a real one also sees infrared, and its response peaks in the near
infrared, so a filament lamp reads brighter than its lux and an LED dimmer. The
angle of the light, the 10 to 20 microsecond rise and fall time, and
temperature.

From Phototransistor, in full.

Projects

## See the Phototransistor in a project

One built-in project uses it. It opens in the editor, already wired.

Boards

## The boards it is shown on

This board has a built-in project with the Phototransistor in it.

- Arduino Uno R3

Keep going

## Keep going

- Analog vs Digital Pins, and ADC Resolution
- Arduino Buzzer and Piezo: Beeps, Notes, Metronome
- Light sensor
- Line sensor, TCRT5000
- Piezo speaker
- Photoresistor sensor module

More parts

## The rest of the bench

Every one of these is drawn and simulated the same way.

Full-size breadboard

A real 0.1 inch grid with the rails and the center channel, 63 columns wide.

Jumper wires

Drag from any pin or hole to any other. Corners snap, and you can drag them.

Power

A supply rail at the voltage you choose.

Ground

The other end of every circuit.

LED

Lights when current flows. Five colors, and the brightness is what your eye would see.

Filament lamp

A tungsten bulb in a holder: an inrush when it is switched on cold, tens of milliseconds to warm up, and dim on half its voltage.

Resistor

Any value you like, with the color bands drawn to match.

ESP32-C3-DevKitM-1

A RISC-V board that runs your firmware at 160 MHz on the real memory map.

Pushbutton

A 12 mm tactile switch. Hold it while the simulation runs.

Raspberry Pi Pico

The RP2040 board on our own Cortex-M0+ core. Pick a program and press Run.

Raspberry Pi Pico W

Raspberry Pi Pico W (RP2040). The same board and the same pinout as a Pico, with the CYW43439 on it. The WiFi is simulated (no radio; real internet through the Cloud panel’s switch), and the on-board LED, which hangs off that chip rather than off GP25, is driven through the same path. Everything else is the Pico.

Raspberry Pi 4 Model B

Raspberry Pi 4 Model B: the 40-pin header, driven by main.py with RPi.GPIO or gpiozero.

See every part

## Wire up the Phototransistor

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.

Start building free Open the editor
