Go Down

Topic: 7 Segment Library problem (Read 5 times) previous topic - next topic

llegoff

#10
Oct 04, 2012, 02:03 pm Last Edit: Oct 04, 2012, 02:16 pm by llegoff Reason: 1
Quote
thanks for the configurations but your library mayby only works for 4xsevensegment displays like that from sparkfun


This library work from 2 digits to 8 digits, and is suitable for common cathode and common anode.
yesterday i modify the library to add the choice of drive common by transistor or directly by arduino pin.
http://laurent.le.goff.free.fr/blog/IMG/zip/sevenseg.zip

example for 2 digit:
Code: [Select]
#include <SevenSeg.h>

/* SevenSeg (Anode or Cathode, Direct or Transistor,a,b,c,d,e,f,g,dp,com1,com2)  [com2 -> com8] */
SevenSeg display2x7(Anode,Transistor,0,1,2,3,4,5,6,7,8,9);

void setup()
{
}

void loop()
{
    display2x7.println(millis()/1000);
    display2x7.multiplex();     //digit 1 on
    delay(10);                  //10ms*2=20ms -> 50hz multiplex
     display2x7.multiplex();     //digit 2 on
     delay(10);
}



example with library MsTimer2

Code: [Select]
/*
 7 segments Libraries

Demonstrates the use a 7 segments display.

This sketch prints " OK." and count 0.1ms.

 The circuit:
* Segment a pin to Resistor 680 to digital pin 0
* Segment b pin to Resistor 680 to digital pin 1
* Segment c pin to Resistor 680 to digital pin 2
* Segment d pin to Resistor 680 to digital pin 3
* Segment e pin to Resistor 680 to digital pin 4
* Segment f pin to Resistor 680 to digital pin 5
* Segment g pin to Resistor 680 to digital pin 6
* Segment dp pin to Resistor 680 to digital pin 7
* Common Anode 1 pin to digital pin 8
* Common Anode 2 pin to digital pin 9
* Common Anode 3 pin to digital pin 10
* Common Anode 4 pin to digital pin 11

Library originally write 1 Sep 2012 by Laurent LE GOFF

This example code is in the public domain.
*/
#include <SevenSeg.h>
#include <MsTimer2.h>

/* SevenSeg (Anode or Cathode, Direct or Transistor,a,b,c,d,e,f,g,dp,com1,com2,com3,com4)  [com2 -> com8] */
SevenSeg afficheur(Anode,Direct,0,1,2,3,4,5,6,7,8,9,10,11);

void setup()
{
 MsTimer2::set(5, interrupt); // 50Hz
 MsTimer2::start();
 afficheur.cursor();
 delay(5000);
 afficheur.setCursor(2);
 afficheur.print('O');
 delay(1000);
 afficheur.print('K');
 delay(1000);
 afficheur.print('.');
 delay(3000);
 afficheur.home();
 delay(3000);
 afficheur.noDisplay();
 delay(1000);
 afficheur.display();
 afficheur.noCursor();
 afficheur.clear();

}

void interrupt()
{
 afficheur.multiplex();
}

void loop()
{
 afficheur.println(millis()/100);
}

Go Up