We are currently experiencing issues with email delivery; this is being resolved as quickly as possible.

stationeers.de Mod workshop · Dominik1199
DE Sign in
  1. Home
  2. IC10 academy
  3. Reading and switching devices: l and s

Chapter 2 · Devices & loop

Reading and switching devices: l and s

With l you fetch values from a device, with s you write values into it.

Lesson 4 of 18 8 min

Math alone does not run a station – the chip should control things. Two instructions do that.

Reading with l

l r0 d0 Temperature

Read it as: “Load the value Temperature from the device on pin d0 into r0.” You assign the device on d0 at the housing with a screwdriver, for example a gas sensor.

Writing with s

s d1 On 1

Read it as: “Set the value On of the device on pin d1 to 1.” A wall light on d1 switches on, 0 switches it off again. A register works instead of the 1 as well: s d1 On r5.

Note

With l the register comes first, with s it comes last. Memory aid: the target is always where the result ends up – the register for l, the device for s.

What if no device is attached?

If nothing hangs on d0, the chip reports the error DeviceNotFound and stays on that line. It retries every tick – plug the device in later and it carries on.

A complete example

l r0 d0 Temperature   # sensor on d0
sub r0 r0 273.15      # to degrees Celsius
s d1 Setting r0       # show it on the display on d1

Diagram

Reading with l, writing with s Gas sensor (d0) Temperature 293.15 IC10 r0 = 293.15 Wall light (d1) On 1 l r0 d0 Temperature device → register s d1 On 1 value → device
l (load) fetches a value from the device into a register, s (store) writes a value from the chip into the device.

Exercise

Task

A gas sensor is attached to d0, a wall light to d1.

  1. Read the sensor’s temperature into r0.
  2. Switch the light on.

Hints

Hint 1

Reading: l r0 d0 Temperature.

Hint 2

Switching on means: set the value On to 1.

Esc
↑ ↓ selectEnter open/ opens search anywhere