#include <mega32.h> #include <alcd.h> #include <stdlib.h> #define output_ddr DDRB #define output_port PORTB char disp[16]; unsigned int i=0, k=0; void display_lcd(void) { lcd_gotoxy(0,0); itoa(i,disp); lcd_puts(disp); lcd_gotoxy(0,1); itoa(k,disp); lcd_puts(disp); } void main(void) { char move=0; output_ddr=0xFF; 2output_port=0x80; GICR=(1<<INT1) | (1<<INT0) | (0<<INT2); MCUCR=(1<<ISC11) | (0<<ISC10) | (1<<ISC01) | (0<<ISC00); lcd_init(16); while (1) { if (GIFR & 0x80) { move=2; GIFR = GIFR | 0x80; } if (GIFR & 0x40) { move=1; GIFR = GIFR | 0x40; } display_lcd(); if (move==1) { output_port=output_port>>1; if (output_port==0) output_port=0x80; } if (move==2) { output_port=output_port<<1; if (output_port==0) output_port=0x01; } for (i=0; i<100; i++) { for (k=0; k<3000; k++) { // looping to create a delay } } } }