Coder Social home page Coder Social logo

pidisplay's Introduction

piDisplay

2 Digit, 7 Segment LED Display Controller Software for the Raspberry Pi. A module for Node.js.

This is a beta version of piDisplay. Everything works correctly as is, but I plan on updating it with a lot more features in the coming weeks and months. This module can display numbers and some letters on a 7 segment, 2 digit LED display that is connected to a Raspberry Pi.

Sample Images

Scrolling Text Across Display

Scrolling Text Across Display

Counting Up on the Display

Counting Up on the Display

Counting Down on the Display

Counting Down on the Display

Pin Layout/Configuration

The model of LED display I am using is a Kingbright DA03-11GWA, and the pinout is shown in the image below. For the full tech sheet, see here. LED Display Pin Layout

As you can see the display uses two pins for common cathodes, seven pins for the LEDs themselves, and pin 2 is not connected. If you do not have the same display, that's fine, just be sure it's common cathode and not common anode, and that it has two common cathode pins and seven pins for the LED segments of the digits. You'll also need to remap the pins manually if your different display does not match the pinout of the display above.

This is how the display's pins are mapped out on the R-Pi's GPIO pins. There wasn't much rhyme or reason to this, and you can feel free to change the defaults if you would like, which I will detail below. All pins are listed by their physical pin number.

LED Pin R-Pi Pin
5 13
10 15
9 18
7 19
1 21
8 22
3 23
6 24
4 26

Installation

npm install pi-display

Need help with installation? See here.

Usage

// Don't forget the extra parentheses to call the constructor function!
var piDisplay = require("pi-display")();

// Displays E7 on the LED display.
piDisplay.displayChars("E7");

// Displays 85.
piDisplay.displayChars(85);

// Scrolls the given string across the display. It looks more natural to scroll
// if you have spaces at either end of the string, but they are not mandatory.
// The second argument is the milliseconds to display each character.
piDisplay.scrollChars(" HI HELLO 1234567890 ", 400);

API

Methods

Method Argument(s) Description
constructor() object ledPins, object cathodePins Used to construct the piDisplay object. Pass in two objects as described in the properties section. Both arguments are optional. See properties for more information.
displayChars() string|number chars Displays one to two static characters on the display. Accepts a string or number (0 to 99). Can be updated very rapidly (without needing to use the clearDisplay() method) in a loop or through some other means.
scrollChars() string sentence, number speed Displays the given sentence in a scrolling style across the LED display, moving one character at a time. The scrolling speed is specified in milliseconds. If no speed is specified, the default 400 is used.
count() string upOrDown, number speed Counts one-by-one either up or down on the display from 0 to 99. Use the string 'up' or 'down' to specify if the method should count up or down. The speed at which each new number is displayed is specified in milliseconds. If no speed is specified, the default 200 is used.
clearDisplay() none Completely clears the display (turns off all the LEDs) and stops any method that is currently executing.

Properties

These properties can only be reassigned at startup. See constructor method for more information.

Property Default Value Description
ledPins object {"top": 23, "topLeft": 26, "topRight": 18, "middle": 21, "bottomLeft": 19, "bottomRight": 22, "bottom": 24} Which physical pin number is matched to which segment of the LED.
cathodePins object {"digitOne": 15, "digitTwo": 13} The physical pin that controls which digit is turned off when set to HIGH.

Credits

I'd like to give a huge thanks to drogon for his excellent Wiring Pi library, Soarez for making the original Node.js bindings for Wiring Pi, and eugeneware for enhancing Soarez's work on the newer Node.js bindings.

pidisplay's People

Contributors

amd940 avatar

Stargazers

 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.