• Blog
  • Parts Sources
  • Form Test
VccGnd

7LED: A quick reference Android app for 7-segment LED symbols

9/12/2012

0 Comments

 
Continuing my fixation with 7-segment LEDs, 7LED is an Android app that serves as a quick reference for 7-segment LED symbols.  Ignoring decimal points, It shows all possible symbols, along with the selected symbol's corresponding lit segments (A-G) and bit encodings.  Here's a video that shows how it works in the Android emulator (a bit fuzzier than on a real device due to screen capture process):

7LED_demo by VccGnd
You can click on the cell of a symbol, or if the small cell sizes make it difficult to click precisely, you can use the trackpad area at the bottom to move the selection cursor.  The About Box displays the bit encoding values, for inclusion in a C program.

You can download 7LED from this page by clicking on its Google play icon.

As mentioned in a previous post, it is possible to simulate 7-segment LEDs with ASCII text.  Here is a console app, 7LEDTest.c, for verifying encodings referenced from the 7LED Android app.  The code also shows the bit encoding constants (LED_A .. LED_G) that can be used with your microcontroller code.
#include <stdio.h>
#include <stdlib.h>

#define LED_A 0x01
#define LED_B 0x02
#define LED_C 0x04
#define LED_D 0x08
#define LED_E 0x10
#define LED_F 0x20
#define LED_G 0x40

static void show(int encoding)
{
    printf(" %c \n",
        (encoding & LED_A) ? '_' : ' ');

    printf("%c%c%c\n",
        (encoding & LED_F) ? '|' : ' ',
        (encoding & LED_G) ? '_' : ' ',
        (encoding & LED_B) ? '|' : ' ');

    printf("%c%c%c\n",
        (encoding & LED_E) ? '|' : ' ',
        (encoding & LED_D) ? '_' : ' ',
        (encoding & LED_C) ? '|' : ' ');
}

int main(int argc, char **argv)
{
    int i;
    char *sEncoding;
    int encoding = 0;

    if (argc < 2)
    {
        printf("7LEDTest encoding [moreEncodings...]\n");
        printf("\tencoding can be decimal or hexadecimal\n");
        printf("\te.g. 7LEDTest 127\n");
        printf("\te.g. 7LEDTest 0x7F\n");

        return 0;
    }

    for(i=1; i<argc; i++)
    {
        sEncoding = argv[i];
        encoding = strtol(sEncoding, NULL, 0);
        
        show(encoding);
    }

    return 0;
}

7LEDTest.c
File Size: 1 kb
File Type: c
Download File

7LEDTest.c has been tested on both Windows (Visual C++ Express) and on Macs (gcc).  You give it decimal or hexadecimal arguments, and you can give it multiple encodings.  For example:
%./7LEDTest 118 63 56 119
   
|_|
| |
 _ 
| |
|_|
   
|  
|_ 
 _ 
|_|
| |
And again, but with arguments in hexadecimal:
%./7LEDTest 0x38 0x79 0x5e 0x7

|  
|_ 
 _ 
|_ 
|_ 

 _|
|_|
 _
  |
  |
0 Comments

Designing 7-segment symbols with a Text Editor

7/27/2012

0 Comments

 
7-segment LED symbols may be quickly designed with a Text Editor using the characters ' ' (space), '|' (vertical bar, the bitwise OR operator in C), and '_' (underscore).  On the first line we use one underscore (preceded by a space) for segment A.  One the 2nd line we use one vertical bar, one underscore, and another vertical bar for segments F, G, and B, respectively.  On the 3rd line we once again have one vertical bar, one underscore, and another vertical bar, but this time for segments E, D, and C, respectively.  We then replace segments that should be disabled with the space character.

Here we have all segments A-G enabled:
 _
|_|
|_|

Some numbers:
    _  _   
  | _| _||_|
  ||_  _|  |

and some letters:
    _     _ 
|_|| ||  |_|
| ||_||_ | |

It works well if you're only interested in a limited number of symbols.
0 Comments

Overview: 7-segment LEDs

7/23/2012

1 Comment

 
I'm adding a series of "Overviews" for readers who may not be coming from a hardware background.

What's the big deal with 7-segment LED displays?  Well, it's not a big deal, but it's not completely trivial either.

Suppose you have a single-digit 7-segment LED display.  One digit can display 0-9 decimal, or 0x0 to 0xF hexadecimal.  Suppose you are only interested in displaying 0 or 1.  The interface is not a single input pin that you set to either GND for 0 or VCC for 1, with all other pins set to GND.  Instead, 7-segment displays have an interface as follows:
Picture
There are 7 input pins, named A-G, each of which controls one segment.  There is usually also a pin controlling the decimal point, typically named DP, but we'll ignore this for simplicity.  To display a 0, you'll need to enable pins A,B,C,D,E,F, but disable pin G.  To display a 1, you'll need to enable pins B and C while disabling all other pins.  There's some logic or lookup involved.  It gets more involved as you expand your display capability from 0..1 to 0..9 or 0x0..0xF.

For four digit 7-segment LED displays, the A-G pins (and DP as well) are shared among the four digits, and 4 more pins indicate which digit the current A-G pins' values should be "sent to."  It's simpler, if at any given time, only one of the four digit selection pins is enabled, with 3 disabled.  You'd have to rotate among the four (like software concept of "round robin") pins.  Now there is not just logic or lookup but state as well.  Furthermore, these 4 "selector-pins" with shared A-G configuration can be in the form of "common anode" or "common cathode."  More details at Wikipedia.
1 Comment

Blinking LED and "Hello, World"

7/20/2012

2 Comments

 
In the software world, it's customary to write a program that prints out "Hello, World" when trying out a new language.  With microcontrollers, the rough equivalent seems to be a blinking LED, as many development boards come with such a sample app.

As a warm-up exercise to getting back into hardware, I thought I'd combine these two ideas, and have a 4-digit 7-segment LED blink "Hola" (conveniently 4 characters long).

Hola by VccGnd
For now, there is some visible flickering.  The 'A' in "Hola" is also partially hidden due to messy wiring.

Parts:
  1. TI Launchpad MSP430 Development Board
  2. 4-digit LED
  3. Small Breadboard
  4. Ribbon cable with female ends
  5. 3-pin cable (2 wires used for Vcc/Gnd, 1 unused)
  6. Male headers
2 Comments

    VccGnd

    Hardware with a software twist.

    Archives

    February 2014
    January 2014
    September 2012
    August 2012
    July 2012

    Categories

    All
    7LED
    Android
    Ascii
    Crystal Free USB
    Crystal-Free USB
    Dev Boards
    MSP430
    Overviews
    PCB
    PIC8
    Sourcing

    RSS Feed

Powered by Create your own unique website with customizable templates.