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.

6 comments:

  1. Thanks for sharing excellent information. Keep sharing such useful information.. Keep sharing such useful information. India visa from usa, You can easily apply for indian visa from usa via Indian Visa website.

    ReplyDelete
  2. The taxation of 봄비벳 casino sub/concessionaires is manufactured from a fixed and fast|a set} part and a variable part. The tax rate is currently of 35%, plus two contributions of as much as} 2% and 3% for social and financial purposes. In addition, a fixed and fast|a set} premium can also be|can be} payable, plus a premium per VIP desk, other desk, and slot machine. In an try and generate revenues for the federal government, gambling in Macau was legalized by the Portuguese authorities in 1849. In the late 19th century, the federal government introduced a licensing system for the fantan homes . It is reported that over 200 gambling homes were required to pay gambling hire to the federal government.

    ReplyDelete