• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 13:56
CEST 19:56
KST 02:56
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Maestros of the Game: Week 1/Play-in Preview9[ASL20] Ro24 Preview Pt2: Take-Off7[ASL20] Ro24 Preview Pt1: Runway132v2 & SC: Evo Complete: Weekend Double Feature4Team Liquid Map Contest #21 - Presented by Monster Energy12
Community News
LiuLi Cup - September 2025 Tournaments2Weekly Cups (August 25-31): Clem's Last Straw?37Weekly Cups (Aug 18-24): herO dethrones MaxPax6Maestros of The Game—$20k event w/ live finals in Paris46Weekly Cups (Aug 11-17): MaxPax triples again!15
StarCraft 2
General
Weekly Cups (August 25-31): Clem's Last Straw? Team Liquid Map Contest #21 - Presented by Monster Energy Heaven's Balance Suggestions (roast me) Geoff 'iNcontroL' Robinson has passed away Speculation of future Wardii series
Tourneys
RSL: Revival, a new crowdfunded tournament series LiuLi Cup - September 2025 Tournaments Sea Duckling Open (Global, Bronze-Diamond) Sparkling Tuna Cup - Weekly Open Tournament Maestros of The Game—$20k event w/ live finals in Paris
Strategy
Custom Maps
External Content
Mutation # 489 Bannable Offense Mutation # 488 What Goes Around Mutation # 487 Think Fast Mutation # 486 Watch the Skies
Brood War
General
Pros React To: herO's Baffling Game BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion BSL Polish World Championship 2025 20-21 September ASL20 General Discussion
Tourneys
Is there English video for group selection for ASL Small VOD Thread 2.0 [Megathread] Daily Proleagues [ASL20] Ro24 Group F
Strategy
Simple Questions, Simple Answers Muta micro map competition Fighting Spirit mining rates [G] Mineral Boosting
Other Games
General Games
Nintendo Switch Thread General RTS Discussion Thread Path of Exile Stormgate/Frost Giant Megathread Warcraft III: The Frozen Throne
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread YouTube Thread
Fan Clubs
The Happy Fan Club!
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
The Automated Ban List TeamLiquid Team Shirt On Sale
Blogs
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Lemme tell you a thing o…
JoinTheRain
How Culture and Conflict Imp…
TrAiDoS
RTS Design in Hypercoven
a11
Evil Gacha Games and the…
ffswowsucks
INDEPENDIENTE LA CTM
XenOsky
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2300 users

[Boredom] A real-time Bitcoin price ticker

Blogs > Loser777
Post a Reply
Loser777
Profile Blog Joined January 2008
1931 Posts
April 13 2013 22:26 GMT
#1
(with Arduino.)

Here is what it looks like:

[image loading]

This is an extremely long rant about something extremely simple.

I recently stumbled upon a fairly common joke sign that reads "This is a
Velociraptor free workplace... it has proudly been [blank] days since the
last velociraptor incident. This particular sign had a post-it tacked on that
had the result of some crude calculation e.g. 71 million years x 365 days/year.
Excusing the fact that there are leap years and that it is highly unlikely that
it has been EXACTLY 71 million years since the last Velociraptor incident,
the post-it is static and unchanging. It will read the same number of days every
day unless someone manually changes it (not going to happen).

As I happened to be somewhat bored, I thought about building a sort of clock
that increments by a day for every day--such clocks are common, but this one
would have 11 digits (enough to support the order of magnitude of the number
of days). I figured the perfect platform to build such a device on would
be the Arduino, connected to some kind of binary-coded decimal to
seven-segment decoder. I knew what I needed existed (the seven-segment
decoder was a mini-project in one of my classes). However, given the number of inputs
on the Arduino and basic economics, it wouldn't make sense to use a
separate decoder for every digit.

Instead, I used one of the greatest tricks in the history of human-interface
devices. Multiplexing. Instead of drawing every number at the same time,
I just draw them one at a time. Really, really fast. Fast enough that
it looks like I'm drawing all of them at the same time. All I need to implement
the multiplexing with the Arduino is to control when a given digit is lit
so that the correct one is drawn--this is easily done with a transistor
acting as a switch. In fact, even though a given digit is comprised of
seven distinct LEDs, they share a common path to ground, so an entire
digit can be switched on and off with a single transistor.

At this point, there just needs to be a little housekeeping and part-sourcing
to build the project. I used the following:
4511 Seven-segment BCD-decoder--this just takes in a binary number from in the
range 0000 to 1001 and spits out seven voltages that will drive the seven-segment
display. I was originally using the 4543BE (which has very similar specs), but
it kept malfunctioning (digits weren't showing up correctly) so I switched to
the 4511. Knightbright (RED) Seven-segment displays (number depends on how many
digits you want. As the number of digits lit up per display is not constant, there needs
to be a current limiting resistor for each segment of each digit--in this case
I was driving everything with 5V and a voltage drop of 2V meant I needed
7*(number of digits) worth of 150 ohm resistors to limit the current to 20mA.
For the switching transistor I picked the 2N3904, which can handle the current
requirements easily (max of 7*20mA). I also used a resistor to limit the base
current on the 2N3904 to 1/10th of what I needed from collector to emitter
(in this case 300ohms). Finally there's a 10K reistor for each of the digital
logic inputs so that I can control what the logic values settle on.

Oh yeah. I also used a breadboard pre-cut jumper wire (I'm not a big fan of
stripping a lot of wire by hand).

This is where it stopped becoming a clock and became a ticker. While prototyping
the circuit, I realized that each of the seven-segment digits I bought had
an eighth LED--a decimal point. I had already added five digits and realized
that 5 significant digits and a decimal point are just right to represent
some $XXX.XX dollar value. That's where bitcoin prices came in.

The software side of the project is so simple that I'm not going to go into
too much detail.
I use a 20-line Python script that parses the last price from mtgox.com and
spits it out as serial data. It refreshed mtgox every 30 seconds and will
retry up to 10 times if the page isn't loading.

The Arduino is constantly drawing the digits and checks if it has received
a new number every two seconds, and if the new number is different, it
increments or decrements the old number until it's equal to the new number
(this gives it a slightly cooler look than just changing the display
in a single instant).

Comments:
Unfortunately I'm not crazy enough to program the microcontroller at the assembly
level or use some fancier display process so basically all of Arduino time
is spent drawing the digits. This means that when it's reading new serial
input there's a half a second when the display blanks.

There's also some floating point rounding
quirks on the Arduino where if you do something
like:
If number A is less than number B
add 0.01 to number A
Else if number A is greater than number B
subtract 0.01 from number A
You end up with some oscillation where A never quite settles on a single
value but jumps between B and B + 0.01. You can solve this by simply
deciding to stop incrementing something when the difference is withing
some number larger than 0.01.

When drawing the digits, there's a brief period (1ms) where everything is switched
off before drawing the next digit, otherwise there is ghosting from the
next digit being drawn bleeding onto the current digit. The 1ms period
is not visible to the human eye.

Getting Arduino to work in Arch Linux is a pain. The IDE doesn't render correctly
if you don't use a full-fledged desktop environment that supports Java's
crap and there's some serial communication configuration that you have to go
through. As a result, I did all of the Arduino stuff in Winblows and later
moved the code over to GNU/Linux when I knew it was working.

Notes:
If you are really dying to see my horrible and ugly code (I have no sense of style, especially Python style), here it is:
https://github.com/eqy/bitticker

6581
LML
Profile Blog Joined March 2007
Germany1768 Posts
April 13 2013 23:00 GMT
#2
no indent after case, this hurts me a little inside;
LML
Loser777
Profile Blog Joined January 2008
1931 Posts
April 13 2013 23:16 GMT
#3
On April 14 2013 08:00 LML wrote:
no indent after case, this hurts me a little inside;

Yeah that Arduino code was a serious hackjob (had to use the crappy IDE instead of my usual text editor).
6581
Please log in or register to reply.
Live Events Refresh
Maestros of the Game
17:00
Group Stage - Group A
Classic vs TriGGeR
Reynor vs SHIN
ComeBackTV 982
SteadfastSC333
IndyStarCraft 162
CranKy Ducklings156
Rex60
EnkiAlexander 49
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 476
SteadfastSC 333
IndyStarCraft 162
BRAT_OK 85
ProTech78
Livibee 72
Rex 60
JuggernautJason23
MindelVK 21
StarCraft: Brood War
Britney 31024
EffOrt 1147
Larva 676
Stork 553
hero 453
ggaemo 327
sSak 261
firebathero 186
Mong 107
Hyun 64
[ Show more ]
Sharp 60
JYJ40
PianO 39
Aegong 30
soO 29
Terrorterran 25
JulyZerg 24
Sacsri 16
Dota 2
The International35885
Gorgc18339
Fuzer 296
Counter-Strike
Fnx 1806
pashabiceps762
Heroes of the Storm
Liquid`Hasu1
Other Games
FrodaN1202
ceh9339
Lowko306
ToD181
Trikslyr158
ArmadaUGS123
C9.Mang089
SortOf56
mouzStarbuck27
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 21 non-featured ]
StarCraft 2
• iHatsuTV 8
• davetesta8
• Reevou 2
• sooper7s
• Migwel
• AfreecaTV YouTube
• LaughNgamezSOOP
• intothetv
• IndyKCrew
• Kozan
StarCraft: Brood War
• Michael_bg 4
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• C_a_k_e 1665
• masondota2588
• WagamamaTV201
League of Legends
• Nemesis4598
• TFBlade739
Counter-Strike
• imaqtpie452
• Shiphtur228
Upcoming Events
OSC
9h 4m
MaNa vs SHIN
SKillous vs ShoWTimE
Bunny vs TBD
Cham vs TBD
RSL Revival
16h 4m
Reynor vs Astrea
Classic vs sOs
Maestros of the Game
23h 4m
Serral vs Ryung
ByuN vs Zoun
BSL Team Wars
1d 1h
Team Bonyth vs Team Dewalt
CranKy Ducklings
1d 16h
RSL Revival
1d 16h
GuMiho vs Cham
ByuN vs TriGGeR
Cosmonarchy
1d 20h
TriGGeR vs YoungYakov
YoungYakov vs HonMonO
HonMonO vs TriGGeR
Maestros of the Game
1d 23h
Solar vs Bunny
Clem vs Rogue
[BSL 2025] Weekly
2 days
RSL Revival
2 days
Cure vs Bunny
Creator vs Zoun
[ Show More ]
Maestros of the Game
2 days
Maru vs Lambo
herO vs ShoWTimE
BSL Team Wars
3 days
Team Hawk vs Team Sziky
Sparkling Tuna Cup
3 days
Monday Night Weeklies
3 days
The PondCast
6 days
Liquipedia Results

Completed

CSL Season 18: Qualifier 2
SEL Season 2 Championship
HCC Europe

Ongoing

Copa Latinoamericana 4
BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Qualifiers
ASL Season 20
CSL 2025 AUTUMN (S18)
RSL Revival: Season 2
Maestros of the Game
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
BLAST.tv Austin Major 2025

Upcoming

LASL Season 20
2025 Chongqing Offline CUP
BSL Polish World Championship 2025 – Warsaw LAN
BSL Season 21
BSL 21 Team A
Chzzk MurlocKing SC1 vs SC2 Cup #2
EC S1
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
MESA Nomadic Masters Fall
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.