Embedded C code for Single 7 Segment display
Sample code for Single 7 Segment display delay subroutine.
Following code can be using for AVR series ICs like: ATmega8, ATmega16, ATmega32.
#include <avr/io.h> #include <util/delay.h> #define DISPLAY_PORT PORTD #define DISPLAY_DDR DDRD #define ZERO 0x77 #define ONE 0x41 #define TWO 0x3B #define THREE 0x6B #define FOUR 0x4D #define FIVE 0x6E #define SIX 0x7E #define SEVEN 0x43 #define EIGHT 0x7F #define NINE 0x6F #define DOT 0x80 int main(void) { DISPLAY_DDR=0xFF; DISPLAY_PORT=0x00; while(1) { DISPLAY_PORT=ZERO; _delay_ms(1000); DISPLAY_PORT=ONE; _delay_ms(1000); DISPLAY_PORT=TWO; _delay_ms(1000); DISPLAY_PORT=THREE; _delay_ms(1000); DISPLAY_PORT=FOUR; _delay_ms(1000); DISPLAY_PORT=FIVE; _delay_ms(1000); DISPLAY_PORT=SIX; _delay_ms(1000); DISPLAY_PORT=SEVEN; _delay_ms(1000); DISPLAY_PORT=EIGHT; _delay_ms(1000); DISPLAY_PORT=NINE; _delay_ms(1000); DISPLAY_PORT=DOT; _delay_ms(1000); } return 0; }
Highlights
-
List of Projects
Navigate through wide range of projects of 8051. Applications including ADC, DAC, LCD, Matrix LEDs, Keypad, Stepper Motor, DC motor, EEPROM, Relay, Timer, Sensors, RTC and much more.
Pick and Place Robot Temperature & Light Controller Rolling Display Matrix LEDs Person Counter & Password Detector Home Security System Data Logger Greenhouse monitor & control Flow computer Electronic Voting Machine Pick & Place Robot Temperature & Light Controller Rolling Display Matrix LEDs Person Counter & Password Detector Data Logger Home Security System Greenhouse monitor & control Flow computer
Read More