Giter Club home page Giter Club logo

8x7seg_counter's Introduction

8x7seg_counter

This C program displays a counter on a 8 digit 7 segment led.

I got one of these...

http://www.dx.com/p/diy8-x-seven-segment-displays-module-for-arduino-595-driver-250813#.VppbZnUrIXc

which appears to be the exact same thing as this:

http://www.dx.com/p/bonatech-8-digit-led-seven-segment-display-module-deep-blue-297686#.VppbdXUrIXc

except it's a dollar cheaper.

I started with this:

https://github.com/hennroja/raspberrypi-yl-3-demo/blob/master/demo-YL3.py

and made a java program which, using pi4j turned out to be way too slow and it just flickered a lot.

I was surprised that the python one ran better than java, but I think it was the pi4j library not so much java vs python on the pi, but I didn't check that out.

So I used wiring pi and ported it to C, and now it's wicked fast, doesn't flicker and uses almost no cpu.

What took me a while to figure out was this:

The first 8 bit byte you send to the display is a bit flag of which of the 8 positions you want to update. The second byte is the pattern you want to update it with. Which means it's really easy to set all 8 digits to the same pattern. But there is no way to present a different display pattern in different digit positions.

The answer is turns out, is that you just have to keep updating it very quickly, and put a delay in after you latch each digit so that the display has time to light up the digit you set. 1 ms is long enough. So you set digit 1's pattern, latch, delay, set digit 2's pattern, latch, delay, repeat for as many of the 8 digits as you want to display, then repeat the process all over, never stopping.

The display hardware is faster than the pi apparently, so you don't have to delay in the program at all in order for the clock or latch kick to take.

The only delay you need is after the latch, so 1) you're not spinning your cpu, and 2) the display shows bright red as opposed to being a dimmer flickering red.

8x7seg_counter's People

Contributors

nixomose avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.