• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 00:25
CET 05:25
KST 13:25
  • 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
[ASL20] Finals Preview: Arrival12TL.net Map Contest #21: Voting10[ASL20] Ro4 Preview: Descent11Team TLMC #5: Winners Announced!3[ASL20] Ro8 Preview Pt2: Holding On9
Community News
2025 RSL Offline Finals Dates + Ticket Sales!9BSL21 Open Qualifiers Week & CONFIRM PARTICIPATION1Crank Gathers Season 2: SC II Pro Teams7Merivale 8 Open - LAN - Stellar Fest3Chinese SC2 server to reopen; live all-star event in Hangzhou22
StarCraft 2
General
RotterdaM "Serral is the GOAT, and it's not close" The New Patch Killed Mech! Could we add "Avoid Matchup" Feature for rankgame Smart servos says it affects liberators as well Chinese SC2 server to reopen; live all-star event in Hangzhou
Tourneys
2025 RSL Offline Finals Dates + Ticket Sales! Crank Gathers Season 2: SC II Pro Teams Merivale 8 Open - LAN - Stellar Fest $5,000+ WardiTV 2025 Championship $3,500 WardiTV Korean Royale S4
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 497 Battle Haredened Mutation # 496 Endless Infection Mutation # 495 Rest In Peace Mutation # 494 Unstable Environment
Brood War
General
BW General Discussion [ASL20] Finals Preview: Arrival BSL Season 21 BSL Team A vs Koreans - Sat-Sun 16:00 CET ASL20 Pre-season Tier List ranking!
Tourneys
[ASL20] Grand Finals BSL21 Open Qualifiers Week & CONFIRM PARTICIPATION ASL final tickets help [ASL20] Semifinal A
Strategy
PvZ map balance Current Meta Soma's 9 hatch build from ASL Game 2 Simple Questions, Simple Answers
Other Games
General Games
Stormgate/Frost Giant Megathread Path of Exile General RTS Discussion Thread Nintendo Switch Thread Dawn of War IV
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
Things Aren’t Peaceful in Palestine US Politics Mega-thread Russo-Ukrainian War Thread YouTube Thread The Chess Thread
Fan Clubs
White-Ra Fan Club The herO Fan Club!
Media & Entertainment
[Manga] One Piece Anime Discussion Thread Korean Music Discussion Series you have seen recently... Movie Discussion!
Sports
Formula 1 Discussion 2024 - 2026 Football Thread MLB/Baseball 2023 TeamLiquid Health and Fitness Initiative For 2023 NBA General Discussion
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
The Benefits Of Limited Comm…
TrAiDoS
Sabrina was soooo lame on S…
Peanutsc
Our Last Hope in th…
KrillinFromwales
Certified Crazy
Hildegard
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1442 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
Germany1772 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
BSL 21
01:00
Open Quali #1
LiquipediaDiscussion
The PiG Daily
22:10
Best Games of SC
Rogue vs herO
MaxPax vs Clem
MaxPax vs Lambo
Clem vs herO
Reynor vs Classic
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nathanias 128
ProTech97
StarCraft: Brood War
Artosis 815
Bale 119
Jaeyun 85
ZZZero.O 36
Icarus 11
Dota 2
monkeys_forever910
XaKoH 592
PGG 566
NeuroSwarm88
LuMiX1
League of Legends
JimRising 822
Super Smash Bros
C9.Mang0658
Other Games
summit1g8101
WinterStarcraft408
Mew2King143
Maynarde110
Livibee71
Organizations
Other Games
gamesdonequick897
BasetradeTV45
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• Berry_CruncH186
• practicex 21
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• RayReign 13
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Rush1016
• Lourlo807
• Stunt637
Upcoming Events
Replay Cast
5h 35m
Streamerzone vs Shopify Rebellion
Streamerzone vs Team Vitality
Shopify Rebellion vs Team Vitality
WardiTV Invitational
7h 35m
CrankTV Team League
8h 35m
BASILISK vs Shopify Rebellion
Team Liquid vs Team Falcon
BSL 21
20h 35m
Replay Cast
1d 5h
BASILISK vs TBD
Team Liquid vs Team Falcon
OSC
1d 7h
CrankTV Team League
1d 8h
Replay Cast
1d 18h
The PondCast
2 days
CrankTV Team League
2 days
[ Show More ]
Replay Cast
3 days
WardiTV Invitational
3 days
CrankTV Team League
3 days
Replay Cast
4 days
BSL Team A[vengers]
4 days
Dewalt vs Shine
UltrA vs ZeLoT
BSL 21
4 days
Sparkling Tuna Cup
5 days
BSL Team A[vengers]
5 days
Cross vs Motive
Sziky vs HiyA
BSL 21
5 days
Wardi Open
6 days
Monday Night Weeklies
6 days
Liquipedia Results

Completed

ASL Season 20
WardiTV TLMC #15
Eternal Conflict S1

Ongoing

BSL 21 Points
CSL 2025 AUTUMN (S18)
BSL 21 Team A
C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
SOOP Univ League 2025
CranK Gathers Season 2: SC II Pro Teams
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025

Upcoming

SC4ALL: Brood War
YSL S2
BSL Season 21
SLON Tour Season 2
BSL 21 Non-Korean Championship
RSL Offline Finals
WardiTV 2025
RSL Revival: Season 3
Stellar Fest
SC4ALL: StarCraft II
META Madness #9
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 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.