Difference between revisions of "Interfacing Seven Segment Display with Starter AVR"
Line 1: | Line 1: | ||
[[category:Starter AVR]] | [[category:Starter AVR]] | ||
− | + | Now we will go further and will interface more complex peripherals. In this tutorial we will interface common anode 7 segment display to the starter AVR board. To get idea about basics of 7 segment display check out our [[Interfacing Seven segment Display with AVR]] tutorail. | |
=Basic= | =Basic= | ||
=Hookup= | =Hookup= |
Revision as of 17:29, 5 April 2016
Now we will go further and will interface more complex peripherals. In this tutorial we will interface common anode 7 segment display to the starter AVR board. To get idea about basics of 7 segment display check out our Interfacing Seven segment Display with AVR tutorail.
Basic
Hookup
Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <avr/io.h> | |
#include <util/delay.h> | |
#define Segment 0x01 | |
int main() { | |
char seg_code[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e}; | |
int cnt; | |
/* Configure the ports as output */ | |
DDRB = 0xff; // Data lines | |
DDRD = 0x01; // Control signal PORTD0 | |
while (1) | |
{ | |
for (cnt = 0x00; cnt < 0x10; cnt++) // loop to display 0-F | |
{ | |
PORTD = Segment; | |
PORTB = seg_code[cnt]; | |
_delay_ms(300); | |
} | |
} | |
} |