#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# Project Clock Help!

edited April 2017

Hey guys! I need help on my clock project. Why is the hour hand not moving? Help!

``````void setup()
{
size(200, 200);
stroke(255);

}
void draw()
{
background(34, 40, 20);
fill(255, 255, 255);
ellipse(width/2, height/2, width, height);

pushMatrix();
translate(width/2, height/2);
fill(255, second()*2, second()*2);
noStroke();
rect(0, -50, 10, 10);
popMatrix();

pushMatrix();
translate(width/2, height/2);
stroke(0);
line(0, 0, 0, -50);
popMatrix();

pushMatrix();
translate(width/2, height/2);
stroke(0);
line(0, 0, 0, -50);
popMatrix();
}
``````
Tagged:

• Line 30 should be

`rotate(radians(hour()*30));`

since there is a full rotation every 12 hours (i.e. 360/ 12 = 30° per hour)

Notice that since the method hour() return integers you will not get smooth movement of the hands but rather it will jump 30° every hour on te hour

To fix that you need to consider fractions of minutes and hours like this

``````void setup()
{
size(200, 200);
stroke(255);
}
void draw()
{
background(34, 40, 20);
noStroke();
fill(255, 255, 255);
ellipse(width/2, height/2, width, height);

pushMatrix();
translate(width/2, height/2);
fill(255, second()*2, second()*2);
rect(0, -50, 10, 10);
popMatrix();

strokeWeight(3);
float minutes = minute() + second()/60.0;
pushMatrix();
translate(width/2, height/2);
stroke(0, 255, 0);
line(0, 0, 0, -50);
popMatrix();

float hours = hour() + minutes/60.0;
pushMatrix();
translate(width/2, height/2);
stroke(0, 0, 255);
line(0, 0, 0, -30);
popMatrix();
}
``````