LCDemo&segment
#include <>
/*F********************************************************************
* We always have to include the library
**********************************************************************/
#include "LedControl.h"
/*I*******************************************************
Now we need a LedControl to work with.
***** These pin numbers will probably not work with your hardware *****
pin 12 is connected to the DataIn
pin 11 is connected to the CLK
pin 10 is connected to LOAD
We have only a single MAX72XX.
********************************************************/
//************************* DEFINES ************************************
//************************* PROTOTYPES ************************************
void writeArduinoOn7Segment();
void scrollDigits();
//************************* VARIABLES ************************************
LedControl lc = LedControl( 12, 11, 10, 1 );
unsigned long delaytime = 250; // always wait a bit between display updates
/*F********************************************************************
*
**********************************************************************/
void
setup()
{
// MAX72XX IN POWER-SAVING MODE ON STARTUP, NEEDS A WAKEUP CALL
lc.shutdown( 0, false );
lc.setIntensity( 0, 8); // SET BRIGHTNESS TO A MEDIUM VALUE
lc.clearDisplay( 0 ); // AND CLEAR DISPLAY
}
/*F********************************************************************
*
**********************************************************************/
void
loop()
{
writeArduinoOn7Segment();
scrollDigits();
}
/*F********************************************************************
* This method will display characters for word "Arduino" one after other on
digit 0.
**********************************************************************/
void
writeArduinoOn7Segment()
{
lc.setChar( 0, 0, 'a', false);
delay( delaytime );
lc.setRow( 0, 0, 0x05 );
delay( delaytime );
lc.setChar( 0, 0, 'd', false );
delay( delaytime );
lc.setRow( 0, 0, 0x1c );
delay( delaytime );
lc.setRow( 0, 0, B00010000 );
delay( delaytime );
lc.setRow( 0, 0, 0x15);
delay( delaytime );
lc.setRow( 0, 0, 0x1D);
delay( delaytime );
lc.clearDisplay( 0 );
delay( delaytime );
}
/*F********************************************************************
* This method will scroll all the hexa-decimal numbers and letters on the
display. You will need at least four 7-Segment digits. otherwise it won't
really look that good.
**********************************************************************/
void
scrollDigits()
{
for( int i =0; i < 13; i++)
{
lc.setDigit( 0, 3, i, false );
lc.setDigit( 0, 2, i + 1, false );
lc.setDigit( 0, 1, i + 2, false );
lc.setDigit( 0, 0, i + 3, false );
delay( delaytime );
}
lc.clearDisplay( 0 );
delay( delaytime );
}