What you learn today
- Show pressure, temperature and oxygen
- Convert units
- A lever switches the lighting
Next to the airlock there should be a panel that shows at a glance whether everything inside is fine. You now know everything you need for it: l and s, LogicTypes, pins, the housing and the display modes.
The setup
| Pin | Device | Job |
|---|---|---|
d0 | gas sensor | measures the room air |
d1 | LED display | pressure in kPa |
d2 | LED display | temperature in °C |
d3 | LED display | oxygen in % |
d4 | lever | lighting on/off |
d5 | wall light | lighting |
db | housing | pressure in atmospheres |
All six pins are in use. That is the limit – a seventh device would need a second chip or the network instructions from week 5.
The conversions
- Temperature: the sensor returns Kelvin, so subtract 273.15. The display gets Mode 4 (Celsius) and only appends the °C.
- Oxygen:
RatioOxygenreturns 0 to 1. Mode 1 (Percent) multiplies by 100 itself – so write the share in unchanged. - Atmospheres: kPa divided by 101.325.
l r1 d0 Temperature
sub r1 r1 273.15
s d2 Setting r1
s d2 Mode 4 # Celsius
Milestones
d1shows the pressure in kPa.d2shows the temperature in °C, mode Celsius.d3shows the oxygen, mode Percent.- The lever on
d4switches the light ond5on … - … and off again.
- The housing shows the pressure in atmospheres.
The program still runs through once. The panel therefore shows the state at start-up. In week 3 it gets a loop and follows every change.
Work milestone by milestone and run the tests after each step. A green milestone stays green if you keep building cleanly.
Diagram
Project task
Task
Build the status panel from the lesson:
d1: pressure in kPad2: temperature in °C, mode Celsius (4)d3: oxygen, mode Percent (1)- lever
d4switches lightd5 db Setting: pressure in atmospheres (kPa / 101.325)
Milestones
- Milestone 1: pressure in kPa
- Milestone 2: temperature in °C
- Milestone 3: oxygen in percent
- Milestone 4: lever switches the light on
- Milestone 5: lever off, light off
- Milestone 6: housing shows atmospheres
Hints
Hint 1
Read the pressure into r0 once and use it twice: for d1 and for the atmospheres.
Hint 2
Percent multiplies by 100 itself – write the share unchanged.
Hint 3
Light: l r3 d4 Open, then s d5 On r3.
Quiz
2 questions. You pass from 60 % – the server does the grading.
Complete the day
- Passed all milestones of the project
- Passed the quiz with at least 60 %
Without an account progress is saved in this browser only.
Report a mistake in this lesson
Please sign in to report. Sign in