What you learn today
- Show Setting on a display
- Pick Mode with DisplayMode
- Set Color
The housing shows a value, but a status panel for the whole base needs more. That is what LED displays are for, in three sizes: small (StructureConsoleLED5), medium and large.
Setting: the number
Whatever is in Setting is what the display shows. The small display has five digits, so up to 99999 in normal mode.
l r0 d0 Pressure
s d1 Setting r0 # shows the pressure in kPa
If it stays dark, check power and On first: a display that is switched off shows nothing, whatever is in Setting.
Mode: the unit
With Mode the display appends a unit. The most important numbers:
| Mode | Name | Display |
|---|---|---|
| 0 | DisplayMode.Default | just the number |
| 1 | DisplayMode.Percent | Setting × 100, whole number, with % |
| 2 | DisplayMode.Power | with W |
| 3 | DisplayMode.Kelvin | with K |
| 4 | DisplayMode.Celsius | with °C |
| 10 | DisplayMode.String | text instead of a number |
Instead of the number you may write the name: s d1 Mode DisplayMode.Celsius is the same as s d1 Mode 4. More about such names comes in week 5.
Celsius does not convert. The mode only appends °C. If 293.15 comes from the sensor, the display reads “293.15 °C”. You subtract the 273.15 yourself.
Percent, on the other hand, does calculate. The display multiplies Setting by 100. RatioOxygen returns 0.21 – write the 0.21 straight in and it reads “21%”. If you multiplied by 100 yourself first, it shows 2100%.
l r1 d0 RatioOxygen # for example 0.21
s d2 Mode 1 # Percent
s d2 Setting r1 # shows 21%
Color: the colour
Color sets the colour of the digits:
| Number | Colour | Number | Colour | |
|---|---|---|---|---|
| 0 | blue | 4 | red | |
| 1 | grey | 5 | yellow | |
| 2 | green | 6 | white | |
| 3 | orange | 11 | purple |
There are names here too: Color.Green is 2, Color.Red is 4. A colour that follows the reading is something you build in week 4 with comparisons.
Diagram
Exercise
Task
A gas sensor is attached to d0, a small LED display each to d1 and d2.
d1: temperature in °C, mode Celsius, colour oranged2: oxygen share in Percent mode – so that it reads “21%” at 21 % oxygen
Hints
Hint 1
Celsius mode is 4, orange is 3 – or DisplayMode.Celsius and Color.Orange.
Hint 2
You convert the temperature yourself: subtract 273.15.
Hint 3
For Percent do not multiply the share by 100, Mode is 1.
Quiz
5 questions. You pass from 60 % – the server does the grading.
Complete the day
- Passed the simulator exercise
- 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