PyRaspBeta

Resistor

A resistor is a two-lead part that limits current and divides voltages. In the shop it costs $0.25 and comes in the one 1/4 W axial size that covers almost everything on a Pi board: the series resistor that keeps an LED from burning out, the pull-up that stops an input floating, and the halves of a voltage divider. Its value is the ohms setting — the simulator accepts anything from 1 Ω to 10 MΩ, so E12 values like 330, 4 700 and 10 000 are a convention, not an enforced rule.

Resistor

Pins

PinWhat it isType
1Lead 1passive
2Lead 2passive
SettingTypeRangeDefault
ohmsnumber1–10000000330

A resistor is not polarised: lead 1 and lead 2 are interchangeable, and a chain like GPIO17 >> Resistor(330) >> LED passes through in either direction.

Wiring it in circuit.py

The classic use — current limiting in series with an LED:

circuit.py
from wiring import *

pi = Pi()

pi.GPIO17 >> Resistor(330) >> LED("red") >> pi.GND

The same part covers pull-up duty; here are the two you will meet most:

pi.V3_3 >> Resistor(10000) >> dht.DATA    # DHT22 data pull-up
pi.V3_3 >> Resistor(4700) >> probe.DQ     # DS18B20 1-Wire pull-up

Driving it in main.py

Nothing to drive: a resistor is transparent to the software. The program drives the LED it protects:

main.py
from gpiozero import LED
from time import sleep

led = LED(17)  # the 330 Ω resistor sits in series in circuit.py

while True:
    led.on()
    sleep(0.5)
    led.off()
    sleep(0.5)

Useful values from the parts in the shop:

UseValueWhy
LED from 3.3 V330 Ω≈ 4 mA through a red LED; 220 Ω is brighter, 1 kΩ dimmer
Pull-up / pull-down10 kΩstrong enough to define a level, weak enough not to load a switch
DS18B20 1-Wire4.7 kΩthe value the 1-Wire bus expects across DQ and VDD
HC-SR04 echo divider1 kΩ + 2 kΩdrops the sensor's 5 V echo to 3.3 V

Electrical notes

  • Rated power is 0.25 W. The model computes P = I²R every solve and warns overpower above the rating — a resistor across a supply rail will trip the judge's damage check.
  • Tolerance is a datafeed setting: 5 % (default) or 1 %. Each part draws one fixed deviation inside the band and keeps it, exactly like a bag of real resistors.
  • The colour bands are drawn from the value: two significant digits, a multiplier and gold (5 %) or brown (1 %), so 330 shows orange-orange-brown and 10000 brown-black-orange.
  • An LED almost always wants a series resistor: R = (Vsupply − Vf) / I. From 3.3 V, 330 Ω gives a red LED about 4 mA, comfortably inside its 20 mA nominal.
  • The simulator does not snap values to the E12 series: Resistor(333) solves as 333 Ω. Round to a real preferred value (the E12 series is 10, 12, 15, 18, 22, 27, 33, 39, 47, 56, 68, 82 per decade) when you care about a bench build.

Simulator vs real hardware

  • The model is a linear resistor with one per-part tolerance offset; there is no thermal drift, voltage coefficient or inductance.
  • The power check is instantaneous. On a bench a 1/4 W part only heats visibly after seconds, and a brief overload may survive.
  • Colour bands follow IEC 60062 two-digit codes for any value, including ones no vendor sells.
  • Resistance is exact at solve time, so divider ratios come out as clean as the marked values suggest.

Going deeper

Further reading