Fancy Clock

From GMod Wiki

Jump to: navigation, search



Contents

A Fancier Clock

Fancy Clock: A Fancier Clock
Page white text.png Description:Displays the time... stylishly.
link=User:Entoros Original Author:Entoros
Calendar.png Created:December 28, 2008
Page white text.png Notes:This version is set to Central Time, just FYI.


Getting the Parts

To start out, we need to spawn all of the components necessary to make the holo circle happen. It'll be mostly in expression for now, but I can put on the regular gates if y'all want. If you're not sure where to place things, look at the image. So, to start out, follow these steps:

I know, it's early.


  1. Spawn a 2x4 tiled plate (from PHX, but not the metal kind).
  2. On the plate, spawn four 7-Segment Displays in a row with the top color as black, and the bottom as green.
  3. In between the two middle 7-Segments, spawn two wire Indicators to make the colon (Value On: 1, Green; Value Off: 0, Black)
  4. Spawn four 7-Segment decoders (Gate - Selection) underneath each 7-Segment display.
  5. Next, spawn an OS Time chip (Gate - Time) and a Time/Date decoder (Gate - Selection).
  6. Create an Expression 2 chip with the following code:
@name Clock
@inputs Hours Minutes Seconds
@outputs Hours1 Hours2 Minutes1 Minutes2 Seconds1 Seconds2 Flash
@persist
if(Hours >= 12){Hours1 = floor((Hours-12)/10)}
elseif(Hours == 0){Hours1 = 1}
else{Hours1 = floor((Hours)/10)}
Hours2 = Hours-12
Minutes1 = floor(Minutes/10)
Minutes2 = Minutes
Seconds1 = floor(Seconds/10)
Seconds2 = Seconds
interval(500)
    if(Flash){Flash = 0}
    else{Flash = 1}

If you choose to make it a clock that shows seconds aswell it should look like this | Giant Clock.jpg

Wiring the Components

Now that everything's just awaiting to be wired, let's get cracking.

  1. Wire the "A" of each segment on the 7-Segment Display to the corresponding letter on the decoder below.
  2. Wire the "Time" of the Time/Date Decoder to the OS Time chip.
  3. Wire the "Hours" of the Expression 2 to the "Hours" of the Time/Date Decoder, "Minutes" to "Minutes", etc.
  4. Wire the "A" of each decoder to its corresponding output of the Expression 2; i.e. the first segment goes to the Hours1, the second to the Hours2, and so on.
  5. Wire the "A" of the Indicator to the "Flash" of the Expression 2.

The Finished Product

The clock should be complete now, with it's own blinking colon in the middle. If you want to make it even fancier, try the following:

Explanation

Wondering how exactly the whole time decoder thing works? Well, if you take a look at your OS Time chip, you'll notice it goes +1 every second. It basically starts at zero (12:00 AM) and adds a second every second, so the Time Decoder just divides the total number of seconds and floors it to get the hours/minutes/seconds. The 7-Segment decoders basically display the ones digit of whatever number given, so we by flooring the number of hours divided by 10, we get the first digit. (it's 7:50 AM; 7/10 = .7, floored = 0, so the first 7-Seg shows 0). The flashing colon is just for fun.

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox