Lamp
A lamp is a light source you can switch. The shop's part costs $5 and is a world-coupled load: on the board it is a small 5 V stand-in, but in the simulated world it adds light to its zone — a light sensor in the same room reads the lamp on top of the daylight — and gives off a little warmth too (its lux value ÷ 20, in watts). That makes it the actuator for lighting control: switch it on when a motion sensor fires in the dark, or keep a plant's shelf lit. It cannot be driven from a GPIO (the stand-in alone draws 100 mA); it goes behind a relay.
Pins
| Pin | What it is | Type |
|---|---|---|
| + | Supply + (switched through a relay) | passive |
| - | Supply − | passive |
| Setting | Type | Range | Default |
|---|---|---|---|
lux | number | 10–20000 | 400 |
Lamp()— Lamp — $5- Pins: 2
- Chain ends:
+ >> lamp >> -
The two leads are a supply loop: + takes the switched supply (through the relay's NO contact) and − returns to the supply ground. Wire the relay into the + side, as the relay + lamp kit does.
Wiring it in circuit.py
A high-trigger relay switching the lamp from the Pi's 5 V rail:
from wiring import *
pi = Pi()
relay = Relay("high") # IN high = contacts closed
lamp = Lamp() # Lamp(lux=1000) for a brighter one
pi.V5 >> relay.dc_plus
pi.V5 >> relay.com # switched supply in at COM
relay.no >> lamp.plus # out at NO, into the lamp
lamp.minus >> relay.dc_minus
relay.dc_minus >> pi.GND
pi.GPIO17 >> relay.signalLamp takes its lux setting by name (10–20000 lux, default 400). It is a world-model number, not something Python can measure.
Driving it in main.py
from gpiozero import OutputDevice
from time import sleep
light = OutputDevice(17)
while True:
light.on()
sleep(5)
light.off()
sleep(5)The program drives the relay; the lighting happens in the world. A real controller reads a light sensor first — the LDR page and the night light recipe show a sensor driving an output.
Electrical notes
- On the board, every load is a 50 Ω stand-in: 5 V across it draws 100 mA, well past a GPIO's safe 16 mA. The relay's contacts switch it instead.
- Its effect on the world scales with
(V ÷ 5 V)², clamped to 1.5, and below 2 % of full it counts as off. - The lamp adds its
luxto the zone's illuminance andlux ÷ 20watts to the zone's heat: the default 400 lux also warms the room by 20 W. A 20000 lux workshop light would add 1 kW of heat — physics has a sense of humour. - Illuminance adds on top of daylight. In an indoor zone the daytime baseline already sits around 300 lux, so a 400 lux lamp is clearly visible day and night — but a light sensor check "dark vs lit" works best at night or in a zone with no daylight.
- A relay switches a lamp on and off only; it cannot dim. For fading light, use PWM on an LED instead.
Simulator vs real hardware
- The behaviour is the shared load model: a 50 Ω resistor across
+/−, a level that follows the supply, and a world effect oflux × levelpluslux ÷ 20 Wof heat. While off it reports no load. - The lamp acts on the zone it is placed in (
indoorby default, changeable in the inspector). A light sensor in the same zone, on its world feed, sees illuminance rise while it is on — day or night. - In the judge, an objective's
environmentpins the sensor readings (e.g.illuminanceLux: 1000) so checks are repeatable; the load still adds light to the zone for sensors left on their world feed. - The canvas shows a glow and the zone's light level while it is on; there is no colour temperature, beam angle or lamp heat-up curve in the model.
- Real mains lamps need proper fixtures and insulation; this is a low-voltage stand-in, and what carries over is the switching lesson, not the wiring.
Going deeper
- The switch that makes it safe: relay module and the primer relays and switching loads.
- Kit: relay + lamp.
- The sensing half: light sensor (LDR) and the light + ADC board.
- Recipe: the night light is the same read-then-switch loop with an LED.
- Sibling loads: heater, fan, pump.
Further reading
- gpiozero: OutputDevice — the class the relay is driven with.
- Raspberry Pi 4 datasheet — why a pin is a signal, not a power supply.
- Adafruit: Power Relay FeatherWing pinouts — switching a load through COM/NO.