Wednesday, November 5, 2014

Character Generator for 7 segments Display

This is a little WebApp helper, for those who want to experiment with 7-segment displays, and draw numbers or even a few other symbols and letters.
It will generate the arduino code for you. For it just draw the symbol you want, give it a description name and click save to add it to the list. Then use the Generate Code button.

A
F
B
G
E
C
D


Add character to List


Saved characters


Arduino Code

Example code

I wrote a sample code that you can use as example.

Also avaliable on GitHub https://github.com/victornpb/display7

/**
 * 7-segments display example code
 * 
 * This code is distributed under The MIT License (MIT)
 * Copyright (c) 2014 victornpb - www.vitim.us
 * created on 18-nov-2014
 */

#define C_ANODE false
const uint8_t myDisplayPins[8] = {3,4,5,6,7,8,9,10}; //dp A B C D E F G

byte font[] = {
  B1111110, //[0] => "0"
  B0110000, //[1] => "1"
  B1101101, //[2] => "2"
  B1111001, //[3] => "3"
  B0110011, //[4] => "4"
  B1011011, //[5] => "5"
  B1011111, //[6] => "6"
  B1110000, //[7] => "7"
  B1111111, //[8] => "8"
  B1111011, //[9] => "9"
  B1110111, //[10] => "A"
  B0000001, //[11] => "dash"
};

void setup(){
 display7Setup(myDisplayPins); //configure myDisplayPins as outputs
}

void loop(){
  
  display7(myDisplayPins, font[0]); //display "0"
  delay(1000);
  display7(myDisplayPins, font[9]); //display "A"
  delay(1000);
  display7(myDisplayPins, font[11]); //display "-"
  delay(1000);
  display7(myDisplayPins, B00000000); //turn all segments OFF
  delay(1000);

  //count 0 to 9
  for(int i=0; i<=9; i++){
    display7(myDisplayPins, font[i]);
    delay(1000);
  }
}

/* Configure pins as outputs */
void display7Setup(const uint8_t displayPins[]){
  for(uint8_t i=0; i<8; ++i){
    pinMode(displayPins[i], OUTPUT);
  }
}

/* Function that writes a bitmap to a 7-segment display */
void display7(const uint8_t displayPins[], byte bitmap){
  if (C_ANODE) { bitmap = ~bitmap; }
  for (uint8_t i=0; i<8; ++i) {
    digitalWrite(displayPins[7-i], (bitmap & 0x1)?HIGH:LOW);
    bitmap >>= 1;
  }
}
Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.

10 comments:

  1. Replies
    1. Great Article
      android based projects

      Java Training in Chennai

      FInal Year Project Centers in Chennai

      Java Training in Chennai

      projects for cse

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
  2. Thanks on your marvelous posting! It is very useful and good.Come on. I want to introduce an get app installs, I try it and I feel it is so good to rank app to top in app store search results, have you ever heard it?

    ReplyDelete