# Turn servo 90 degrees during sun rise and sun set

**URL:** <https://discourse.nodered.org/t/turn-servo-90-degrees-during-sun-rise-and-sun-set/61463>\
**Category:** General\
**Created:** [18 April 2022 20:56 UTC](https://discourse.nodered.org/t/turn-servo-90-degrees-during-sun-rise-and-sun-set/61463 "2022-04-18T20:56:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![astrojav](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/astrojav/32/58738_2.png) [@astrojav](https://discourse.nodered.org/u/astrojav)\
**Post date:** [18 April 2022 20:56 UTC](https://discourse.nodered.org/t/turn-servo-90-degrees-during-sun-rise-and-sun-set/61463/1 "2022-04-18T20:56:11Z")

</div>

Hi folks,

I just completed an all-sky-cam build which should only take pictures at night. To protect the camera sensor due to sunlight, the idea is to put a type of "cap" over the lens, an example below. The "cap" should start moving slowly over the lens as the sun rises and remove itself as the sun sets.

The controller is a Raspberry Pi and the servo is an SG90. I've already wired it to the RPi and can send commands to the servo with the "pi gpiod" node. Below is the flow as I currently have it to move it 90 degrees over. Any help on expanding the flow with the idea mentioned above is highly appreciated.

Jairo

Flow:

```auto
[{"id":"2a58b503dd48e2f8","type":"pi-gpiod out","z":"fdb1688a952261c8","name":"","host":"localhost","port":8888,"pin":"2","set":"","level":"0","out":"ser","sermin":"500","sermax":"1500","freq":"800","x":600,"y":180,"wires":[]}]

```

Example:

 ![Screenshot_20220123-184209_Facebook](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/0/e0e6fc848e0d6456154dbcf6c694104b8e5b0738.jpeg)  
 ![Screenshot_20220123-184200_Facebook](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/2/a267f5c2198914228441ddc33baac5fea58e23c5.jpeg)

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [18 April 2022 23:54 UTC](https://discourse.nodered.org/t/turn-servo-90-degrees-during-sun-rise-and-sun-set/61463/2 "2022-04-18T23:54:38Z")

</div>

Why don’t you try using one of the ‘Cron’ contrib nodes?  
[https://flows.nodered.org/search?term=Cron&type=node](https://flows.nodered.org/search?term=Cron&type=node)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 June 2022 23:54 UTC](https://discourse.nodered.org/t/turn-servo-90-degrees-during-sun-rise-and-sun-set/61463/3 "2022-06-17T23:54:51Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
