ARQUITECTURA DE UN MICRO CONTROLADORDescripción completa
#define F_CPU 4000000UL #include #include #include short P!_"alue0$ char i0 $ void %nit_&'void( ) //Confi*uro el Puerto + para ,- y +++ 00000000$ P1,+ 0-FF$ //2C,%"1 L13 pilluP esistor para +0+5 L2 67,2+2 P+8 %7, 0 //Confi*uro C para salida ++C 09FF$ P1,C 0900$ //&2:%L%,1 6L P:5 C1!1 32L%+2 ++: '<
case 5= P1,C 000000$ return $ case 4= P1,C 0:0000$ return $ case ?= P1,C 0:000$ return $ case G= P1,C 000$ return $ case = P1,C 00$ return $ case D= P1,C 0$ return $ E return $ E
short ead_2+C_C&0'void( ) 2+C32 H '<<2+3C($ hile ''2+C32 '<<2+3C(( I0900($ return 2+C$ E
/J%3 ',%!60_1"F_vect( ) ,C7,0 'unsi*ned char(P!_"alue$ if ''P%7+ 09F0(0-F0( ) P1,+ 0-0F$ E else ) P1,+ H 0-F0$ E EJ/ int ;ain'void( ) unsi*ned char tecla$ char sec_val 0$ short 2+C_val0$ //short +C_porc0$ short "in0.0$ %nit_&'($ hile '( ) //secuencia
2+C_val ead_2+C_C&0'($ "in '?.0J'doule(2+C_val(/085.0$ if ''"in>0('"in <0.?(( 3ecuencia_Leds'0($ if ''"in>0.?('"in <.0(( 3ecuencia_Leds'($ if ''"in>.0('"in <.?(( 3ecuencia_Leds'8($ if ''"in>.?('"in <8.0(( 3ecuencia_Leds'5($ if ''"in>8.0('"in <8.?(( 3ecuencia_Leds'4($ if ''"in>8.?('"in <5(( 3ecuencia_Leds'?($ if ''"in>5.0('"in <5.?(( 3ecuencia_Leds'G($ if ''"in>5.?('"in <4.0(( 3ecuencia_Leds'($ if ''"in>0(( 3ecuencia_Leds'D($ //,2628 _delay_;s'00($ //,2625 ,-_Usart''unsi*ned char('2+C_val '0-00FF((($ //,- de los Dits L3: ,-_Usart''unsi*ned char('2+C_val >>D(($ //,- de los Dits L3: //,262 4 if'tecla I 8??( ) P1,C tecla$ if 'tecla K2K( ) P!_"alue ?$ if 'P!_"alue>8??( ) P!_"alue 8??$ E E P1,C tecla$ if 'tecla KCK( ) P!_"alue ?$ if 'P!_"alue < 0( ) P!_"alue 0$ E E 1C0'unsi*ned char(P!_"alue$ E E E