Blinky Clock

Blinky Clock preview image

1 collaborator

Marcus_snell Marcus Snell (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 5.3.1 • Viewed 295 times • Downloaded 33 times • Run 0 times
Download the 'Blinky Clock' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


WHAT IS IT?

A visual clock, where hours and minutes are represented by dots and seconds are represented by the sequential movement of the dots.

HOW IT WORKS

This model pulls the time from your computer, converts the time from a string to a list, and checks to see if the time (H:H:M:M) has changed. If so, the model checks to see if the hour, minute, and/or second has changed, then translates the decimal time to binary for only the h/m/s that has changed.

HOW TO USE IT

First, press "Initialize Clock". Then press "Start Clock".

NETLOGO FEATURES

to clock Converts the date-to-time primitave from a string to a numerical list

*In order to get the dots to blink sequentially, based only upon the blocs currently lit up, I had to create 3 counters and a check.

wigcheck Tracks the number of blocs (a 'bloc' defined as one of the 4 color-time blocs) currently lit up, updated every minute

wigcount Counts how many blocs have 'wiggled' (i.e. had a dot shifted), increments for each bloc wiggled, and resets when wigcount = wigcheck

wigtrip Tracks if a bloc has wiggled this second and, if so, does not allow any other blocs to wiggle

hc1/hc2/mc1/mc2 Tracks which of the 4 blocs has wiggled this go-around (a 'go-around' defined as the number of seconds it takes for wigcount to increment up to wigcheck) and does not let them wiggle until next go-around

Also, blocs with all 9 dots lit up do not wiggle.

CREDITS AND REFERENCES

Created By: Marcus Snell Email: marcus.l.snell@gmail.com

Comments and Questions

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

breed [cubes cube]

globals[
  realtime
  time
  h1
  h2
  m1
  m2
  s1
  s2
  time0
  group0
  group1
  group2
  group3
  wigcount
  wigcheck
  wigtrip
  hc1
  hc2
  mc1
  mc2
  ]

to setup
  ca
  set-default-shape cubes "cylinder"
  set group0 patches with [pxcor = 0]
  set group1 patches with [pxcor >= 2 and pxcor <= 4]
  set group2 patches with [pxcor >= 6 and pxcor <= 8]
  set group3 patches with [pxcor >= 10 and pxcor <= 12]
  set time0 [0 0 0 0]
  clock
  keeptime
end 

to clock
  set realtime date-and-time
  set h1 read-from-string item 0 realtime
  set h2 read-from-string item 1 realtime
  set m1 read-from-string item 3 realtime
  set m2 read-from-string item 4 realtime
  set s1 read-from-string item 6 realtime
  set s2 read-from-string item 7 realtime
  set time (list h1 h2 m1 m2 s1 s2)
end 

to go
  set time0 time
  clock
  if time0 != time[keeptime]
end 

to keeptime
  wiggle
  hour1
  hour2
  min1
  min2
  show time
end 

to wiggle
  set wigtrip 0
  if wigcount >= wigcheck[
    set hc1 0
    set hc2 0
    set mc1 0
    set mc2 0
    set wigcount 0
  ]
end 

to hour1
  let subgroup group0 with [count cubes-here > 0]
  let subcount count subgroup
  ifelse subcount != item 0 time[
    if subcount < item 0 time[ask n-of (item 0 time - count subgroup) group0 with [count cubes-here = 0] [sprout-cubes 1 [set color 105]]]
    if subcount > item 0 time[ask group0 with [count cubes-here > 0] [ask cubes-here [die]]]
  ]
  [if subcount > 0 and hc1 = 0 and wigtrip = 0 [
      ask one-of group0 with [count cubes-here > 0] [ask cubes-here [move-to one-of group0 with [count cubes-here = 0]]]
      set hc1 1
      set wigcount wigcount + 1
      set wigtrip 1
      ]
  ]
end 

to hour2
  let subgroup group1 with [count cubes-here > 0]
  let subcount count subgroup
  ifelse subcount != item 1 time[
    if subcount < item 1 time[ask n-of (item 1 time - count subgroup) group1 with [count cubes-here = 0] [sprout-cubes 1 [set color 65]]]
    if subcount > item 1 time[ask group1 with [count cubes-here > 0] [ask cubes-here [die]]]
  ]
  [if subcount > 0 and subcount < 9 and hc2 = 0 and wigtrip = 0 [
      ask one-of group1 with [count cubes-here > 0] [ask cubes-here [move-to one-of group1 with [count cubes-here = 0]]]
      set hc2 1
      set wigcount wigcount + 1
      set wigtrip 1
      ]
  ]
end 

to min1
  let subgroup group2 with [count cubes-here > 0]
  let subcount count subgroup
  ifelse subcount != item 2 time[
    if subcount < item 2 time[ask n-of (item 2 time - count subgroup) group2 with [count cubes-here = 0] [sprout-cubes 1 [set color 45]]]
    if subcount > item 2 time[ask group2 with [count cubes-here > 0] [ask cubes-here [die]]]
  ]
  [if subcount > 0 and mc1 = 0 and wigtrip = 0 [
      ask one-of group2 with [count cubes-here > 0] [ask cubes-here [move-to one-of group2 with [count cubes-here = 0]]]
      set mc1 1
      set wigcount wigcount + 1
      set wigtrip 1
      ]
  ]
end 

to min2
  let subgroup group3 with [count cubes-here > 0]
  let subcount count subgroup
  ifelse subcount != item 3 time[
    if subcount < item 3 time[ask n-of (item 3 time - count subgroup) group3 with [count cubes-here = 0] [sprout-cubes 1 [set color 15]]]
    if subcount > item 3 time[ask group3 with [count cubes-here > 0] [ask cubes-here [die]]]
    recount
  ]
  [if subcount > 0 and subcount < 9 and mc2 = 0 and wigtrip = 0 [
      ask one-of group3 with [count cubes-here > 0] [ask cubes-here [move-to one-of group3 with [count cubes-here = 0]]]
      set mc2 1
      set wigcount wigcount + 1
      set wigtrip 1
      ]
  ]
end 

to recount
  set wigcheck 0
  if (count group0 with [count cubes-here > 0]) > 0 [set wigcheck wigcheck + 1]
  if (count group1 with [count cubes-here > 0]) > 0 and (count group1 with [count cubes-here > 0]) < 9 [set wigcheck wigcheck + 1]
  if (count group2 with [count cubes-here > 0]) > 0 [set wigcheck wigcheck + 1]
  if (count group3 with [count cubes-here > 0]) > 0 and (count group3 with [count cubes-here > 0]) < 9 [set wigcheck wigcheck + 1]
end 

There are 2 versions of this model.

Uploaded by When Description Download
Marcus Snell about 8 years ago Fixed wiggle counters in min2 Download this version
Marcus Snell about 8 years ago Initial upload Download this version

Attached files

File Type Description Last updated
Blinky Clock.png preview Preview for 'Blinky Clock' about 8 years ago, by Marcus Snell Download

This model does not have any ancestors.

This model does not have any descendants.