AVR Development Board – AVR-DK20A User Manual
36
x = PINC;
if (x==0x01)
PORTB = 0xff; //reading input data from PORTC and output to PORTB
else
PORTB = 0x00;
} while(1);
}
A.6 Experiment 3 – Buzzer
//Experiment 3
//Title : Buzzer
//Jumper for Buzzer : LK1
//Jumper Setting: BZ-A0
void main() {
DDRA = 0x01; // Set direction to be output
do {
PORTA = 0x01; // Turn ON Buzzer
Delay_ms(200); // 200ms delay
PORTA = 0x00; // Turn OFF buzzer
Delay_ms(200); // 200ms delay
} while(1);
}
A.7 Experiment 4 – 7-Segment 0-9 decimal counter
//Experiment 4
//Title : A Decimal 7-segment display counter, count from 0 to 9
//Jumper for 7segment : LK9-LK14
//Jumper Setting: B0-A,B1-B,B2-C,B3-D,B4-DIG1,B5-DIG2
int e,j;
void main() {
DDRB = 0xff; // Set direction to be output
do{
/* set ports */
j=0;
for (e=0;e<10;e++)
{
if (j<9)
{
j = j + 1;
PORTB = 0x20 + j;
delay_ms(200);
}
else
{
j = 0;
PORTB = 0x20 + j;
delay_ms(200);
}