This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2008-03-01 07:07:31

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Simulate a Clock

One of my teachers wanted some software to do simulations and I said I'm sure I couild knock up something using Scratch  smile

So i've come up with the idea of simulating an analogue (or digital for that matter) clock with second, minute and hour hand/digits.

As I was playing with it, I found myself trying out various ideas and then getting lost as to which one would be best to try to teach  sad

Do you fancy having a go yourselves and see what you come up with.

The idea is to be able to have less able pupils acheive something and the gifted something really good with the rest inbetween (as always is the case!).

Have a play and publish your efforts.  smile

Target age is 8-9 and something must be acheived in 1 hour lesson so the less blocks used the better  smile

Any other ideas for using Scratch to simulate things would be welcome.

regards

Simon

PS
This is open to anyone so if there are any younger Scratchers who'd liek to help out I'd be very grateful  smile

Offline

 

#2 2008-03-01 09:22:19

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Simulate a Clock

A clock simulation is actually quite complex, requiring use of the timer, rotational angles and finite number system (ie, counting back to zero when you get to 60).

Whilst thinking about something simpler, I put together this:

http://scratch.mit.edu/projects/Mayhem/110364

See what you think.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#3 2008-03-01 13:41:09

FPSFelix
Scratcher
Registered: 2008-02-06
Posts: 100+

Re: Simulate a Clock

here, i made a fairly simple representation of a clock, but it cant sense the current time(scratch cant do that) so it starts at exactly noon.
look at it on my profile.


this is what i brought you, this you can keep.
this is what i brought, you may forget me.
i promise to depart, just promise one thing...
kiss my eyes and lay me to sleep.

Offline

 

#4 2008-03-01 16:33:23

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Simulate a Clock

1st off - Please don't look at others code before posting your attempt otherwise I think it will spoil your own original thinking!  smile

Having said that, FPFFelix's project outcome is exactly the sort of thing I was thinking about so it would be a good idea to have a look at it before startinf your own coding running (but don't look at the code if you don't want to corrupt your own original thinking )  smile

@Mayhem
I don't think it needs to be complex - if you think about the way toy clocks worked (or Timex watches for that matter  lol  ) when I was little (just a set of simple gears IIRC)  smile

What I'm looking for is code that could be simply explained and taught to a range of 8 year olds (who are possibly familiar with scratch and have done some simple work with it before - (using If Green Flag,next costume and wait to produce simple stop go animations)

regards

Simon

Last edited by SimpleScratch (2008-03-01 16:38:09)

Offline

 

#5 2008-03-01 20:18:30

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Simulate a Clock

Here's a slightly different approach.  I wanted the hands to move fairly continuously between the clock markings so all the hands move once per second.

http://scratch.mit.edu/projects/Paddle2SeeFixIt/110896

The code is very straightforward.  It does use a message to carry the timing pulse to all the hands but it doesn't use the sensor block or use any variables or counting.  There are also some scripts to allow setting of the hands but they could be omitted.

More advanced students could turn it into a chiming clock or an alarm clock.  Really advanced students could add in phases of the moon or add in a tide level hand.

Last edited by Paddle2See (2008-03-01 20:36:23)


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#6 2008-03-01 20:22:40

Rukqo
Scratcher
Registered: 2008-01-17
Posts: 100+

Re: Simulate a Clock

I still think we should be able to connect Scratch to our clock.

Offline

 

#7 2008-03-01 20:59:10

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Simulate a Clock

One of the first clock simulations in scratch was by Graham:
http://scratch.mit.edu/projects/Graham/7266
Nine months ago now.

Offline

 

#8 2008-03-01 21:14:46

Rukqo
Scratcher
Registered: 2008-01-17
Posts: 100+

Re: Simulate a Clock

I still think we could use the computer's clock more-like connect it to Scratch. I know it will work because I've tries C programming before.

Offline

 

#9 2008-03-02 04:59:35

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Simulate a Clock

@Paddle2See

Very nice - I used the a similar approach myself but not quite as elegant (or as simple in fact  smile  )

More advanced students could turn it into a chiming clock or an alarm clock.

Brilliant idea!!!

regards
Simon

Offline

 

#10 2008-03-02 05:57:57

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Simulate a Clock

Clever in its simplicity - in my head I wanted it much more complicated but that works beautifully.

Another thing advanced students could do - try to "tie" the hour and minute hand together so that you can only set the clock to a "real" time.  (at the moment you can have the hour hand exactly on an hour but the minute hand anywhere)


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#11 2008-03-02 07:03:06

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Simulate a Clock

kevin_karplus wrote:

One of the first clock simulations in scratch was by Graham:
http://scratch.mit.edu/projects/Graham/7266
Nine months ago now.

This version is very simple...it uses the timer instead of a timing pulse. 

There is an error in the constant being used to set the hour hand, however.  The constant inthe program is currently 0.0016667 when it should be 0.008333.  I know because I made the same mistake when I did my clock.  You think the rate for the hour hand should be 1/60 the rate of the minute hand (60 minutes per hour) but really it's 1/12 the rate of the minute hand (12 rotations of minute hand = 1 rotation of hour hand).


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#12 2008-03-02 08:02:24

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Simulate a Clock

You think the rate for the hour hand should be 1/60 the rate of the minute hand (60 minutes per hour) but really it's 1/12 the rate of the minute hand (12 rotations of minute hand = 1 rotation of hour hand).

Could you run that past us again :confused:

regards

Simon

Offline

 

#13 2008-03-02 09:35:20

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Simulate a Clock

BTW - here is my original effort.
http://scratch.mit.edu/projects/SimpleScratch/111185


regards

Simon

Offline

 

#14 2008-03-02 10:30:40

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Simulate a Clock

SimpleScratch wrote:

You think the rate for the hour hand should be 1/60 the rate of the minute hand (60 minutes per hour) but really it's 1/12 the rate of the minute hand (12 rotations of minute hand = 1 rotation of hour hand).

Could you run that past us again :confused:

regards

Simon

Simple - its easy to get caught out, thinking that the hour hand should move 1/60th the distance that the minute hand moves, as 1 hour = 60 minutes.  Doing that would mean the hour hand moved 1/60th of the distance of the minute hand.

But there are 12 hours on the clock face so when the minute hand makes a full rotation, the hour hand should move 1/12 of a rotation, not 1/60th.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#15 2008-03-02 12:35:40

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Simulate a Clock

I'm just going to write this down as I'm thinking

We all seem to be agreed that for every rotation of the secondhand - the minute had should move 1/60th of...


Right - I've worked out at this point where we are deviating from each other.

I agree, In a discrete moving clock, where the minute hand moves on every discrete minute, the hour hand has to move on 1/12th of a rotation every time the minute hand completes a full rotation.

But the same is not true in a pure analogue clock (well the second hand isn't pure in our simulations - but ignorning that discrepancy  smile ,  all hands are moving every single second so the hour hand does move at a rate of 1/60th of the minute hand.

Does this seem like a workable grand unified theory to you?  smile

regards

Simon

Offline

 

#16 2008-03-02 12:38:00

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Simulate a Clock

SimpleScratch wrote:

BTW - here is my original effort.
http://scratch.mit.edu/projects/SimpleScratch/111185


regards

Simon

Thanks, Mayhem, for expanding on my overly terse explanation.  To see a derivation of the rotation rates, see the project notes on my original project

http://scratch.mit.edu/projects/Paddle2SeeFixIt/110896

SimpleScratch, you have the same error in your project as Graham does (and I used to have) only, you can actually see it with your project since you have it cranked up so fast.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#17 2008-03-02 12:54:06

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Simulate a Clock

SimpleScratch wrote:

I

But the same is not true in a pure analogue clock (well the second hand isn't pure in our simulations - but ignorning that discrepancy  smile ,  all hands are moving every single second so the hour hand does move at a rate of 1/60th of the minute hand.

The hour hand needs to cover 1 hour in the time it takes for the minute hand to cover 60 minutes.    Hence your figure of 1/60.

BUT!

The difficulty lies in the fact that not only do the hands move at different speeds, but the distance travelled means different things depending on the hand.

1 rotation of minute hand = 60 mins
1 rotation of hour hand = 12 hours (not 60!)

One full rotation of the clockface of the minute hand is one hour.

1/60th of a rotation of the clock face by the hour hand is NOT an hour, it is 12 minutes.  To cover an hour on the clock face, the hour hand must move 5/60ths of a rotation, (1/12th of a rotation).

Hence Paddle's point that the angle moved by the hour hand needs to be 1/12 of the angle moved by the minute hand, NOT 1/60th


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#18 2008-03-02 15:10:32

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Simulate a Clock

Doh!  smile

Not much hope for the kids if I can't add up properly in the 1st place  smile

V0.2 has the correction!  smile

http://scratch.mit.edu/projects/SimpleScratch/111436

regards
Simon

Last edited by SimpleScratch (2008-03-02 15:12:26)

Offline

 

#19 2008-03-09 22:41:16

FPSFelix
Scratcher
Registered: 2008-02-06
Posts: 100+

Re: Simulate a Clock

ok, i just made a digital version that is pretty simple if you want to check it out
the only real time it took was importing all the #s


this is what i brought you, this you can keep.
this is what i brought, you may forget me.
i promise to depart, just promise one thing...
kiss my eyes and lay me to sleep.

Offline

 

#20 2008-03-16 05:15:14

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Simulate a Clock

@FPSFelix - nice work  smile

@everyone
Could you have a look at this project
http://scratch.mit.edu/projects/SimpleScratch/121077
that was written by one of my pupils (ignore any algorithmic errors  smile  )


I can't understand why Sprite1 (the hour hand) doesn't seem to respond to its script commands  sad

Is it a bug or am I missing something?

regards

Simon

Offline

 

#21 2008-03-16 05:45:57

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Simulate a Clock

Heh - because it is set to "only face left and right" instead of "can rotate"


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#22 2008-03-16 06:12:57

SimpleScratch
Scratcher
Registered: 2007-05-25
Posts: 100+

Re: Simulate a Clock

Ta  smile

regards

Simon

Offline

 

#23 2008-03-16 14:40:01

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: Simulate a Clock

The problem is that Sprite1 has the left-right arrow clicked, so it is not allowed to rotate.

Offline

 

#24 2008-03-27 17:28:13

MrSleeman
Scratcher
Registered: 2008-01-25
Posts: 4

Re: Simulate a Clock

Hello everyone.
Here is my 1st attempt.
http://scratch.mit.edu/projects/MrSleeman/128923
I went for the 3 variables (H, M and S) method.
The second hand moves every pulse, the minute and hour hands only every minute

On my computer you can drag the hands around to set the time (full screen mode) but this does not work when I run it online.  Does anyone know why?

Last edited by MrSleeman (2008-03-27 17:29:35)

Offline

 

#25 2008-03-27 18:32:41

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Simulate a Clock

MrSleeman wrote:

Hello everyone.
Here is my 1st attempt.
http://scratch.mit.edu/projects/MrSleeman/128923
I went for the 3 variables (H, M and S) method.
The second hand moves every pulse, the minute and hour hands only every minute

On my computer you can drag the hands around to set the time (full screen mode) but this does not work when I run it online.  Does anyone know why?

Yes, the problem is that the "On Clicked" event acts differently between the Scratch and the the Online environments.  In Scratch, "On Clicked" triggers on Mouse Down but online, "On Clicked" is triggered on Mouse Up.  If you switch to a Forever If loop, it should work in both places.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

Board footer