Help with solar panel tracking project

Hey everyone, so I am completely new to Arduino, and I'm having some problems. So my goal is to make my servo motor rotate 12 degrees in 1 hour. This is my full code:

#include <Servo.h>

Servo myservo; // create servo object to control a servo

int pos = 0; // variable to store the servo position

void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop() {
delay(36000ul) ;
write(12)
}

It says that I haven't defined write. How do I do that, and what else should I add onto my code? Thank you so much!!!!

Look very carefully at the example servo code, in the library examples of the IDE. Then look at what you've written, and come back with questions.

write() is supposed to be defined in servo.h.

You are missing a semicolon after write() and that might be confusing the complier. (Error messages aren't always that helpful.)

Your code delays (doing nothing) and then rotates to 12 degrees. I don't think that's what you want.

You should also set the starting position before any delay.

I think you want to rotate 1 degree at a time (1degree every 5 minutes), I don't think you can use fractional degrees but I'm not sure.) And you need to increment the angle. If you set it to 12 degrees twice it will just stay at 12 degrees, not move 12 degrees more.

For code development, shorten the delay so you don't have to wait so long to see if it's working. Maybe 12 degrees per minute or something like that.

Ok thank you so much! I'll try that right now

Also you're right, error msgs aren't very helpful lol

Wait so should I use serial instead of write then? So like

serial(12);
???

The .write() is a method which is appled on an object which is myservo. The code should be:

myservo.write(12);

1 hour = 60x60x1000 ms = 3600000 ms

Also so lets say I want the motor to start at 25 degrees and move 12 degrees every hour, what would be the code for that? I tried...

void loop() {
delay(36000ul) ;
write(12);
servo.write(25);
}

Oh ok, thank you!!

So then how do you make it start at say 25 degrees, and then move 12 degrees more every hour? Like how would you code that? I'm sorry for asking so many questions.. I feel kinda bad now

Note: Since the servo can only go to 180, this will stop after about 12 hours.

Note: You will get smoother action if you move one degree every five minutes instead of 12 degrees every hour.

#include <Servo.h>

Servo myservo; // create servo object to control a servo

int pos = 25; // variable to store the servo position

void setup()
{
  myservo.attach(9); // attaches the servo on pin 9 to the servo object
  myservo.write(pos);
}

void loop()
{
  delay(60ul * 60ul * 1000ul); // Wait one hour
  pos += 12;
  myservo.write(pos);
}

Hey, so I am trying to make a solar panel rotate a certain number of degrees every hour using a servo motor and arduino. Can you guys help me troubleshoot some problems and make sure my code is good?
This is my code:

#include <Servo.h>

Servo myservo; // create servo object to control a servo

int pos = 0; // variable to store the servo position

void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop() {
delay(2000) ;
myservo.write(12);
}

void loop() {
delay() ;
myservo.write();
}

void loop() {
delay() ;
myservo.write();
}

Also, for the myservo.write(12), it ends up being more than 12 degrees, and it stops after like 2 turns, and also the turns are in opposite directions, I want them to be in the same direction.
Thank you so much!

P.S. The last 2 void loops aren't complete yet, I have to measure the sun's angle for those and then I'll add numbers onto them

I edited the last part so it wasn't void, also I want these to move in the same direction

loop(2) {
delay(2000) ;
myservo.write(12);
}

loop() {
delay() ;
myservo.write();
}

loop() {
delay() ;
myservo.write();
}

If someone answers, could you please give me the code and also explain it so I have both?? This is my first time using arduino, so I am struggling a lot right now, I hope to get better at it soon!!!!

Installation and Troubleshooting is for Problems with the Arduino IDE itself NOT your project. It says so in the description of the section.

Therefore I have moved your post here. Please be more careful where you post in future.

You may want to read this before you proceed:-
how to get the best out of this forum

I'm really sorry, I must have misclicked

In order to try and help you we need to know not only the code you are using but also the schematic. Hand drawn is fine, Fritzing is not.

It is important that you post code correctly in code tags as mentioned in that link I posted.

It is good if you have used and understood at least some of the concepts in the examples in the IDE. You seem not to know how code works.

Your code must contain a setup function but only one.
Your code must contain a loop function but only one.

I have merged your cross-posts @vanyag.

Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting can result in a suspension from the forum.

In the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Hey everyone, what is the code for resetting my servo motor back to it's original starting point? So it's finished its rotation all the way, and now it needs to just rotate all the way back to the start so it can redo the whole thing over again.
Here is my code:

#include <Servo.h>

Servo myservo; // create servo object to control a servo

int pos = 25; // variable to store the servo position

void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
myservo.write(pos);
}

void loop(3)
{
delay(2000);
pos +=12;
myservo.write(pos);
}

The problem is that the code you use just keeps on going, with the servo eventually hitting the end stop. That will damage your servo so limit it to the maximum value you want to use.

Then use

maxPos =  // you put the value of the maximum position here
void loop() // the loop function takes in no argument
{
while(pos < maxPos){
        delay(2000);
       pos +=12;
       myservo.write(pos);
}
// now send it back
   pos = 25;  // the place it started from
  myservo.write(pos);

}