• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 17:30
CEST 23:30
KST 06:30
  • 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
RSL Season 1 - Final Week6[ASL19] Finals Recap: Standing Tall12HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0
Community News
Esports World Cup 2025 - Brackets Revealed4Weekly Cups (July 7-13): Classic continues to roll2Team TLMC #5 - Submission extension1Firefly given lifetime ban by ESIC following match-fixing investigation17$25,000 Streamerzone StarCraft Pro Series announced7
StarCraft 2
General
Who will win EWC 2025? The GOAT ranking of GOAT rankings Esports World Cup 2025 - Brackets Revealed Esports World Cup 2025 - Final Player Roster RSL Revival patreon money discussion thread
Tourneys
RSL: Revival, a new crowdfunded tournament series FEL Cracov 2025 (July 27) - $8000 live event $5,100+ SEL Season 2 Championship (SC: Evo) WardiTV Mondays Sparkling Tuna Cup - Weekly Open Tournament
Strategy
How did i lose this ZvP, whats the proper response Simple Questions Simple Answers
Custom Maps
External Content
Mutation # 482 Wheel of Misfortune Mutation # 481 Fear and Lava Mutation # 480 Moths to the Flame Mutation # 479 Worn Out Welcome
Brood War
General
Flash Announces (and Retracts) Hiatus From ASL Starcraft in widescreen BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion A cwal.gg Extension - Easily keep track of anyone
Tourneys
CSL Xiamen International Invitational [BSL20] Non-Korean Championship 4x BSL + 4x China [Megathread] Daily Proleagues 2025 ACS Season 2 Qualifier
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Path of Exile CCLP - Command & Conquer League Project The PlayStation 5
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 Summer Games Done Quick 2025! Things Aren’t Peaceful in Palestine Stop Killing Games - European Citizens Initiative
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread [\m/] Heavy Metal Thread
Sports
Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 2024 - 2025 Football Thread NBA General Discussion NHL Playoffs 2024
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Men Take Risks, Women Win Ga…
TrAiDoS
momentary artworks from des…
tankgirl
from making sc maps to makin…
Husyelt
StarCraft improvement
iopq
Trip to the Zoo
micronesia
Customize Sidebar...

Website Feedback

Closed Threads



Active: 635 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
Germany1764 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
RotterdaM Event
16:00
Rotti Stream Rumble 5k Edition
RotterdaM833
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 833
ZombieGrub120
Nathanias 108
JuggernautJason77
UpATreeSC 64
ProTech57
Livibee 18
StarCraft: Brood War
Larva 548
firebathero 340
sas.Sziky 73
IntoTheRainbow 8
Dota 2
syndereN374
NeuroSwarm32
League of Legends
Grubby5127
Counter-Strike
fl0m1497
Stewie2K705
Foxcn408
Super Smash Bros
PPMD59
Liquid`Ken33
Heroes of the Storm
Liquid`Hasu514
Khaldor263
Trikslyr54
Other Games
summit1g8931
shahzam590
mouzStarbuck320
C9.Mang0171
Pyrionflax99
Mew2King76
Sick51
Organizations
Other Games
gamesdonequick4911
BasetradeTV21
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 17 non-featured ]
StarCraft 2
• kabyraGe 187
• Adnapsc2 20
• sooper7s
• AfreecaTV YouTube
• Migwel
• intothetv
• LaughNgamezSOOP
• Kozan
• IndyKCrew
StarCraft: Brood War
• Eskiya23 17
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota22637
League of Legends
• Doublelift2363
Other Games
• imaqtpie2058
• Shiphtur446
Upcoming Events
Replay Cast
2h 30m
Replay Cast
12h 30m
WardiTV European League
18h 30m
ShoWTimE vs sebesdes
Percival vs NightPhoenix
Shameless vs Nicoract
Krystianer vs Scarlett
ByuN vs uThermal
Harstem vs HeRoMaRinE
PiGosaur Monday
1d 2h
uThermal 2v2 Circuit
1d 18h
Replay Cast
2 days
The PondCast
2 days
Replay Cast
3 days
Epic.LAN
3 days
CranKy Ducklings
4 days
[ Show More ]
Epic.LAN
4 days
BSL20 Non-Korean Champi…
4 days
Bonyth vs Sziky
Dewalt vs Hawk
Hawk vs QiaoGege
Sziky vs Dewalt
Mihu vs Bonyth
Zhanhun vs QiaoGege
QiaoGege vs Fengzi
Sparkling Tuna Cup
5 days
Online Event
5 days
BSL20 Non-Korean Champi…
5 days
Bonyth vs Zhanhun
Dewalt vs Mihu
Hawk vs Sziky
Sziky vs QiaoGege
Mihu vs Hawk
Zhanhun vs Dewalt
Fengzi vs Bonyth
Liquipedia Results

Completed

2025 ACS Season 2: Qualifier
RSL Revival: Season 1
Murky Cup #2

Ongoing

JPL Season 2
BSL 2v2 Season 3
CSL 17: 2025 SUMMER
Copa Latinoamericana 4
Jiahua Invitational
BSL20 Non-Korean Championship
Championship of Russia 2025
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25
BLAST Rivals Spring 2025
MESA Nomadic Masters

Upcoming

CSL Xiamen Invitational
CSL Xiamen Invitational: ShowMatche
2025 ACS Season 2
CSLPRO Last Chance 2025
CSLPRO Chat StarLAN 3
BSL Season 21
K-Championship
RSL Revival: Season 2
SEL Season 2 Championship
uThermal 2v2 Main Event
FEL Cracov 2025
Esports World Cup 2025
Underdog Cup #2
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
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.