Exercise 10, Task 6.2 Motion-controlled Lights

raq154
Neuling
Neuling
Beiträge: 2
Registriert: 14. Nov 2016 18:30

Exercise 10, Task 6.2 Motion-controlled Lights

Beitrag von raq154 »

Description of task:
Create a trait Lights that connects the motion detectors to the lights. Whenever any motion detector in a room detects
motion, we want to turn on all available lights in the same room. Since it is usually not necessary to turn the lights on
during the day, the automatic control of lights should only be enabled in the evening between 6pm and 11pm.

Hint: Our motion detectors only report the position where they have sensed any motion last. However, they do not tell
us when motion has been detected. We can solve this issue by using timeouts. You can use the method Signal.changed
to create an event that is fired when the motion detector reports a new position and indicates that motion has been
detected. When the event is fired the first time, create a timer with a delay of 100ms that indicates that there is no
motion anymore. Reset the timer whenever motion is detected before the timer action has been executed.

To implement this I can simply use the clock of the "House" to check current time (hours.now >= 18 && hours.now <= 23). I don't understand the hint provided. Can anybody explain how this hint is linked with the task?

ManuelWeiel
Mausschubser
Mausschubser
Beiträge: 72
Registriert: 7. Okt 2014 11:38

Re: Exercise 10, Task 6.2 Motion-controlled Lights

Beitrag von ManuelWeiel »

Our motion detectors only report the position where they have sensed any motion last.
This means, that the motion detectors don't report the time, when motion was detected, but only where motion was detected (the position).
In this task you are supposed to turn on the lights when there was movement (time dependent).
So you have to find a way to get from the signal "Hey I've had some movement at position x,y" to "Hey I've got some now".

The rest of the hint tries to show how this can be done. Additional hint: When can you be sure that there is movement now?

andiderp
Erstie
Erstie
Beiträge: 20
Registriert: 14. Apr 2012 13:37

Re: Exercise 10, Task 6.2 Motion-controlled Lights

Beitrag von andiderp »

Should the lights turn off after a specific amount of time?

ManuelWeiel
Mausschubser
Mausschubser
Beiträge: 72
Registriert: 7. Okt 2014 11:38

Re: Exercise 10, Task 6.2 Motion-controlled Lights

Beitrag von ManuelWeiel »

andiderp hat geschrieben:Should the lights turn off after a specific amount of time?
create a timer with a delay of 100ms

Antworten

Zurück zu „Archiv“