AVR Development Board – AVR-DK20A User Manual
34
Appendix – Experiment and Tutorial Answer in MikroC
A.1 Experiment 1 – Output 55H to LEDs Display
//Experiment 1
//Title : Output value 10101010 on 8-bit output LEDs
//Jumper for LEDs : LK9 to LK16
//Jumper Setting: L0-B0, L1-B1, L2-B2, L3-B3, L4-B4,L5-B5, L6-B6, L7-B7
void main() {
DDRB = 0xFF; // Set direction to be output
PORTB = 00;
do {
PORTB = 0xaa; // display 10101010 on LEDs
} while(1);
}
A.2 Tutorial 1a – Blinking LEDs
//Tutorial 1a
//Title : Blinking LEDs
//Jumper for LEDs : LK9 to LK16
//Jumper Setting: L0-B0, L1-B1, L2-B2, L3-B3, L4-B4,L5-B5, L6-B6, L7-B7
void main() {
DDRB = 0xFF; // Set direction to be output
do {
PORTB = 0x00; // Turn OFF diodes on PORTB
Delay_ms(200); // 1 second delay
PORTB = 0xFF; // Turn ON diodes on PORTB
Delay_ms(200); // 1 second delay
} while(1);
}
A.3 Tutorial 1b – Running LEDs
//Tutorial 1b
//Title : Running LEDs
//Jumper for LEDs : LK9 to LK16
//Jumper Setting: L0-B0, L1-B1, L2-B2, L3-B3, L4-B4,L5-B5, L6-B6, L7-B7
int i;
int j;
int t;
void main() {
DDRB = 0xFF; // Set direction to be output
do {
j = 0x01;
t = 0x80;
for ( i=0; i < 7; i++){
portb = j;