# Simple sweep beginner

**URL:** <https://forum.arduino.cc/t/simple-sweep-beginner/860348>\
**Category:** General Guidance\
**Created:** [May 11, 2021, 4:50am UTC](https://forum.arduino.cc/t/simple-sweep-beginner/860348 "2021-05-11T04:50:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcaponed](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@alcaponed](https://forum.arduino.cc/u/alcaponed)\
**Post date:** [May 11, 2021, 4:50am UTC](https://forum.arduino.cc/t/simple-sweep-beginner/860348/1 "2021-05-11T04:50:27Z")

</div>

hi im really beginner about arduino project. and i wanna ask . how to make code of sweep servo with scheduled time without use timer module . example servo that sweep 90 degree and back to 0 position every 1 hour.

can you help me?

---

<div class="post-metadata">

**Author:** ![LarryD](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/larryd/32/215550_2.png) [@LarryD](https://forum.arduino.cc/u/LarryD)\
**Post date:** [May 11, 2021, 5:07am UTC](https://forum.arduino.cc/t/simple-sweep-beginner/860348/2 "2021-05-11T05:07:15Z")

</div>

You need to review the following thread which will show you how to make a **none blocking** Timer.

> [@Using millis() for timing. A beginners guide](https://forum.arduino.cc/t/using-millis-for-timing-a-beginners-guide/483573):
>
> Part 1 It is not usually long before new Arduino users discover that although the delay() function is easy to use it has side effects, the main one of which is that its stops all activity on the Arduino until the delay is finished (not quite true, I know, but that is usually how the problem presents itself). When this occurs the new user is usually directed to the BlinkWithoutDelay example sketch (BWoD) and/or the excellent thread entitled Several things at the same time. [Several things at the…](http://forum.arduino.cc/index.php?topic=223286.0)

After you master how to make a Timer, then come up with a schematic showing how the project hardware is connected.

You should be aware servos should not be powered from the Arduino, they need their own power supply, probably 6VDC, this can be four AA batteries or a 5V @ 1 to 2Amp cell phone charger.

The servo power supply must share a common ground connection with the Arduino.

* * *

You can add a relay circuit to control the power to the servo.

Use this relay to disconnect the servo battery power when it is not needed to move will help extend the life of the batteries.

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [May 11, 2021, 10:50am UTC](https://forum.arduino.cc/t/simple-sweep-beginner/860348/3 "2021-05-11T10:50:34Z")

</div>

@alcaponed, your topic has been moved to a more suitable location on the forum.

---

<div class="post-metadata">

**Author:** ![79galinakorczak](https://avatars.discourse-cdn.com/v4/letter/7/7ba0ec/32.png) [@79galinakorczak](https://forum.arduino.cc/u/79galinakorczak)\
**Post date:** [May 11, 2021, 11:17am UTC](https://forum.arduino.cc/t/simple-sweep-beginner/860348/4 "2021-05-11T11:17:07Z")

</div>

```cpp
// 10 sec on, 1 hour off
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
  //delay(1000); // wait for a second
   delay(1000 *10);
  digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
  //delay(1000);   
  delay(1000*360); // wait for a second
}

```

---

<div class="post-metadata">

**Author:** ![dave-in-nj](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@dave-in-nj](https://forum.arduino.cc/u/dave-in-nj)\
**Post date:** [May 11, 2021, 12:00pm UTC](https://forum.arduino.cc/t/simple-sweep-beginner/860348/5 "2021-05-11T12:00:41Z")

</div>

"DELAY()"

blocks all code in loop()

Best to be avoided.

But at the very beginners level it appears work.

A cheat is

delaymicro(1);  
Counter++;

If (Counter \>= 60000 ){  
Counter=0;  
Minutespaused++;  
}

If(Minutespaused \>=86000)  
Minutes paused=0;  
.....Now do your code.  
}

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [September 8, 2021, 12:00pm UTC](https://forum.arduino.cc/t/simple-sweep-beginner/860348/6 "2021-09-08T12:00:48Z")

</div>

Closed on September 8, 2021, 12:00pm UTC

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