What you learn today
- Switch grow lights on a schedule
- Show ripeness
- Control lights together
The greenhouse gets its own control: grow lights on a schedule, a lamp for the harvest and a lever for permanent light while you work inside. Everything from this week in one chip.
The setup
| Device | Prefab | Name |
|---|---|---|
| grow lights | StructureGrowLight | Pflanzenlicht |
| hydroponics devices | StructureHydroponicsTrayData | – |
| wall light | StructureWallLight | Ernte |
| LED display | StructureConsoleLED5 | Reife |
| lever | StructureLogicSwitch | Dauerlicht |
All grow lights have the same name. A single sbn switches them together, whether there are two or twenty. The trays need no name, lbs reads them by their type.
Milestones
- Light on schedule: in every period of
PERIODticks the grow lights are on for the firstONticks, then off. - Ripeness: the lamp “Ernte” lights up as soon as a plant is ripe. The display “Reife” shows the progress of the most advanced plant in percent.
- Permanent light: if the lever is on, the grow lights stay on. The schedule keeps running in the background.
- Failure: if the trays are missing, the display shows 0 and the lamp “Ernte” is off. If the lever is missing, the schedule applies.
Times for the test
In the test the times are short: PERIOD 30 and ON 20 ticks. In the game you enter your real plan, for example 7200 and 4800 for one hour with 40 minutes of light.
define PERIOD 30 # ticks per light period (in game e.g. 7200)
define ON 20 # light ticks per period (in game e.g. 4800)
move time 0
The move time 0 sits before the start label. That way the plan starts cleanly from the beginning after every upload.
The lever reports its position in Open. If it is missing, Average returns NaN. sgtz turns that into 0, and the schedule applies – without an extra check.
Do not build the schedule with sleep. During sleep the chip stands still. The harvest lamp and the lever would only react after it wakes up.
Diagram
Project task
Task
Build the greenhouse control as described above. Devices and names:
- grow lights “Pflanzenlicht” (
StructureGrowLight, two of them) - three hydroponics devices (no names)
- wall light “Ernte”, LED display “Reife”
- lever “Dauerlicht” (
StructureLogicSwitch, valueOpen)
The milestones are listed above the editor.
Milestones
- Milestone 1: light on schedule
- Milestone 2: ripeness
- Milestone 3: permanent light
- Milestone 4: trays and lever fail
Hints
Hint 1
Schedule: add time time 1, mod time time PERIOD, slt light time ON.
Hint 2
Lever: lbn … Open Average, then sgtz and or light light always.
Hint 3
Harvest and ripeness as in lesson 74: lbs … Mature Maximum and lbs … MaturityRatio Maximum.
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