AVR Development Board – AVR-DK20A User Manual
35
delay_ms(150);
j = j << 1; //shift y value to left
}
for (i =0; i < 7; i++){
portb = t;
delay_ms(150);
t = t >> 1; //shift t value to right
}
}
while (1);
}
A.4 Experiment 2 – Dip Switch to LEDs Display
//Experiment 2
//Title : 8-Way DIP Switch to LEDs
//Jumper for LEDs : LK9 to LK16
//Jumper Setting [LEDs]: L0-B0, L1-B1, L2-B2, L3-B3, L4-B4, L5-B5, L6-B6, L7-B7
//Jumper for Switches : LK17 to LK24
//Jumper Setting [SW1]: DP0-C0,DP1-C1,DP2-C2,DP3-C3,DP4-C4,DP5-C5,DP6-C6,DP7-C7
//Output port: PortB
//Input Port: PortC
void main() {
int x;
DDRB = 0xFF; // Set direction to be output
DDRC = 0x00; //Set direction to be input
PORTC=0x00;
PORTB = 0x00;
do {
x = PINC;
PORTB = x; //reading input data from PORTC and output to PORTB
} while(1);
}
A.5 Tutorial 2 – Sensing 01h to light ON 8-bit LEDs, else turn OFF LEDs
//Tutorial 2
//Title : Sensing 01 from DIP switch and light up all the LEDs
// else turn OFF all LEDs
//Jumper for LEDs : LK9 to LK16
//Jumper Setting [LEDs]: L0-B0, L1-B1, L2-B2, L3-B3, L4-B4, L5-B5, L6-B6, L7-B7
//Jumper for Switches : LK17 to LK24
//Jumper Setting [SW1]: DP0-C0,DP1-C1,DP2-C2,DP3-C3,DP4-C4,DP5-C5,DP6-C6,DP7-C7
//Output port: PortB
//Input Port: PortC
void main() {
int x;
DDRB = 0xFF; // Set direction to be output
DDRC = 0x00; //Set direction to be input
PORTC=0x00;
PORTB = 0x00;
do {