In Embedded system design, seven segment displays are playing a major role as numerical visual indications. Seven segment LED displays are brighter, more attractive and provide a far viewing distance as well as a wider viewing angle as compared to LCD displays. Its available wide dimensions (0.3 inch to 6 inch) and different colors (RED, GREEN, BLUE, ORANGE, WHITE). It can display digits from 0 to 9 and quite a few characters like A, b, C, d, E, e, F, n, o, P, t, u, etc. This intractable is about interfacing 8 digits of 7 segment display by using popular MAX7219 display driver with Arduino Uno.
/*
Demonstrates the use of MAX7219 and 2 of 4x7 Segment display.
The Arduino circuit connection for 7219:
* MAX7219 DIN pin to digital pin 4
* MAX7219 LOAD pin to digital pin 3
* MAX7219 CLOCK pin to digital pin 2
*
Name:- M.Pugazhendi
Date:- 05thJul2016
Version:- V0.1
e-mail:- [email protected]
*/
#include
// inputs: DIN pin, CLK pin, LOAD pin. number of chips
LedControl mydisplay = LedControl(4, 2, 3, 1);
unsigned int count = 0;
unsigned int count_one = 0;
unsigned int count_two = 0;
void setup()
{
mydisplay.shutdown(0, false); // turns on display
mydisplay.setIntensity(0, 15); // 15 = brightest
mydisplay.setDigit(0, 0, 9, false);
mydisplay.setDigit(0, 1, 8, false);
mydisplay.setDigit(0, 2, 7, false);
mydisplay.setDigit(0, 3, 6, false);
mydisplay.setDigit(0, 4, 5, true);
mydisplay.setDigit(0, 5, 4, false);
mydisplay.setDigit(0, 6, 3, false);
mydisplay.setDigit(0, 7, 2, false);
}
void loop()
{
count++;
if((count*7) >= 9999)
{
count = 0;
}
count_one = HexToBCD(count);
count_two = HexToBCD(count*7);
mydisplay.setDigit(0, 0, ((count_two>>12)&0x0F), false);
mydisplay.setDigit(0, 1, ((count_two>>8)&0x0F), false);
mydisplay.setDigit(0, 2, ((count_two>>4)&0x0F), false);
mydisplay.setDigit(0, 3, ((count_two>>0)&0x0F), false);
mydisplay.setDigit(0, 4, ((count_one>>12)&0x0F), false);
mydisplay.setDigit(0, 5, ((count_one>>8)&0x0F), false);
mydisplay.setDigit(0, 6, ((count_one>>4)&0x0F), false);
mydisplay.setDigit(0, 7, (count_one&0x0F), false);
delay(500);
}
/**************************************************************************
*!
* \brief Coverts hex into BCD
*
* This function will coverts hex into BCD
*
* \param[in] byte
* \param[out] byte
* \return Nill
*
*
**************************************************************************/
unsigned int HexToBCD(unsigned int number)
{
unsigned char i=0;
unsigned int k = 0;
while(number)
{
k = ( k ) | ((number%10) << i*4);
number = number / 10;
i++;
}
return(k);
}