7-segment LED display
are the widely used displays in many applications that can display any
character or digital value. We have already discussed the 7-segment
concept in our previous post which defines it as the combination of 8
LEDs forming "8" display and divided as the common cathode and common
anode.
Now, learn the concept of multiplexing by which you can connect many 7-segment displays to a single port of 8051 microcontroller. Earlier we discussed about the 7-segment up counter display in which 3 7-segments are connected to 3 different ports and up counter is running from 0-999. But, it had limitation. You can not connect many 7-segments to a single port.
- In the above diagram you can see how i have connected the 4 7-segment display to the port P2 of 8051 microcontroller. It is a schematic diagram which i have drawn in Proteus ISIS professional. But, in practical you can implement the same concept. Use 8 pins of any port of microcontroller and connect the single pin to same pin of all 7-segment LED display and Hence, the multiplexing has been implemented.
Now, learn the concept of multiplexing by which you can connect many 7-segment displays to a single port of 8051 microcontroller. Earlier we discussed about the 7-segment up counter display in which 3 7-segments are connected to 3 different ports and up counter is running from 0-999. But, it had limitation. You can not connect many 7-segments to a single port.
Multiplexing of 7-segment:
- In the above diagram you can see how i have connected the 4 7-segment display to the port P2 of 8051 microcontroller. It is a schematic diagram which i have drawn in Proteus ISIS professional. But, in practical you can implement the same concept. Use 8 pins of any port of microcontroller and connect the single pin to same pin of all 7-segment LED display and Hence, the multiplexing has been implemented.
Code:
#include"REGx52.h" #define seg_data P2 sbit seg1=P0^1; sbit seg2=P0^2; sbit seg3=P0^3; int ones=0,tens=0,hundreds=0,l; void display_digit(int ); void delay(); void main() { seg1=seg2=seg3=1; while(l<=999) { ones=l%10; tens=(l/10)%10; hundreds=(l/100); display_digit(ones); seg1=0; delay(); seg1=1; display_digit(tens); seg2=0; delay(); seg2=1; display_digit(hundreds); seg3=0; delay(); seg3=1; l++; } } void delay() { long int k; for(k=0;k<1000;k++); } void display_digit(int c) { switch(c) { case 0: seg_data=0xbf; break; case 1: seg_data=0x06; break; case 2: seg_data=0x5b; break; case 3: seg_data=0x4f; break; case 4: seg_data=0x66; break; case 5: seg_data=0x6d; break; case 6: seg_data=0x7d; break; case 7: seg_data=0x07; break; case 8: seg_data=0x7f; break; case 9: seg_data=0x6f; break; } }
Comments
Post a Comment