loading

Measured values are of great importance in all experiments. So lets make a small project wherein we'll learn how to incorporate a seven segment with an Arduino. The seven segement used here is with the MAX7219 IC . Though it may seem of little importance of why to interface only a seven segment display with arduino, believe me, with the incorporation of this little module,you can do greater projects.

So the whole idea here is to get some display on the seven segment and to understand the commands, which I know otherwise is a cumbersome and time consuming process.

Lets begin

Step 1: Requirements

As our main aim is only to understand the seven segment(MAX7219 ic) not many components are required

  • Arduino
  • MAX7219 ic Seven segment display
  • Wires

There is a library that is required to be included in order to work with this module. Get it downloaded from the below link and place it in your 'libraries' folder of 'Arduino'

https://github.com/wayoda/LedControl

Step 2: Connections

Just five pins so connections should not be any trouble.

The module is provided with an option for cascading with more modules of its kind, thus forming a larger display. Lets consider only one module for simplicity to begin with.

Make connections as follows in accordance with the code

VCC- 5v of arduino

GND- gnd of arduino

Din- pin 12

CS(Load)-pin 10

Clk-pin 11

Dout is connected to the Din of the next module.

Step 3: Important Functions--Must Read Section

My main intention of this DIY lies in this section.

lets now see the important commands and how to use them

1)LedControl( dataPin, clkPin, csPin, numDevices=1);

This command is used to create an LedControl. There are four parameters passed to this i.e pin no of 'data','clk','cs','no of modules cascaded'

in our case this becomes (12,11,10,1)

2)getDeviceCount();

This function returns a integer which specifies the number of devices connected. The return type is int. I havent used it in this project.

3)shutdown(addr, true/false);

This function is used in the setup. The purpose of this function is to define the mode of the display. If 'true' the device will be in power down mode. So we need to make it false for our operations. Another parameter is address which is integer and gives the address of the display. In our case the address of the display is zero

4)setScanLimit(addr, limit);

This function is of very little importance at this stage. It is used to immediately after a LedControl is created in the setup. Can refer datasheet for details. addr holds its previous meaning while limit refers to the number limit to be displayed.

5)setIntensity(addr, intensity);

This function is used to set the intensity of the display. There is no ambiguity here. addr refers to the address of the display while intensity can be any integer from 0-15. I've set it to 8.

6)clearDisplay(addr);

This command is used to clear the display screen,i.e o turn off all the LEDs.

7)setLed(addr, position, segment, true/false);

This command is often less used. addr holds the usual meaning. 'position' refers to the position of the seven segment display which holds integer value from 0-7. 'segment' refers to the position of the segment of each seven segment( I've indicated in the image). True is to glow the LED indicated in the position passed in the previous two arguments.

8)setRow(addr, position, value);

This function is used to display any characters that are possible on the seven segment. 'position' like above represents which of the eight is selected. 'value' is the equivalent value in hexadecimal or binary of the character to be displayed, by making the LEDs in those positions high.

for uppercase 'C' it is 0x4E or B01001110

9)setDigit(addr, position, number, decimal point(t/f));

This is also a widely used function. It is directly used to display the digit.'number' stands for the number to be displayed. Last parameter is true if decimal point is required.

10)setChar(addr, position, character,decimal point(t/f));

This is used to display the characters directly.In the place of 'character' a character is passed in inverted coma.


It is important to note two things. Firstly, all the functions addressed above are called with an object of LedControl, which is created globally. Secondly, we are dealing with a common cathode seven segment display.

With this background knowledge,we are set to write out own code.


Step 4: The Code

<p>#include "LedControl.h"

LedControl lc=LedControl(12,11,10,1);

unsigned long delaytime=250;

void setup() {
lc.shutdown(0,false);
lc.setIntensity(0,8);
lc.clearDisplay(0);
}

void disp_something()
{
lc.setRow(0,3,0x4E);
lc.setDigit(0,2,0,false);
lc.setDigit(0,1,0,false);
lc.setRow(0,0,0x1E);
delay(5*delaytime);
lc.clearDisplay(0);
}

void moving_digits()
{
for(int i=0;i<8;i++)
{
lc.setDigit(0,i,i,false);
delay(2*delaytime);
}
lc.clearDisplay(0);
delay(delaytime);
}

void loop() {
disp_something();
moving_digits();
}

Nothing much left to explain here.

First 'COOL' is displayed, followed by 0 1 2 3 4 5 6 7

Step 5: Further Development

The purpose of this Instructable was to handy in a bigger project. So in a project where values are obtained, assign them to a variable and extract all the digits one by one and display on the seven segment.

I hope I'll get to see this being implemented in amazing way

So keep thinking,keep doing

About This Instructable

1,108views

14favorites

License:

Bio: Engineering student
More by electricitypinto:Arduino and micro switch Arduino controlled seven segment IR remote controlled led with arduino 
Add instructable to: