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.
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 d1Diagram
Exercise
Task
A gas sensor is attached to d0, a wall light to d1.
- Read the sensor’s temperature into
r0. - Switch the light on.
Hints
Hint 1
Reading: l r0 d0 Temperature.
Hint 2
Switching on means: set the value On to 1.