Documentos de Académico
Documentos de Profesional
Documentos de Cultura
3 //define los indicadores #define inicio_proceso PORTB.0 #define nivel_bajo PORTB.1 #define buzzer PORTB.2 #define ventilador PORTB.3 #define valvula PORTB.4 #define humidificador PORTB.5 #define on 1 #define off 0 bit inicio; bit alarma; static unsigned int tiempo; // Boton que activa todo el proceso //pulsador interrupt [EXT_INT0] void ext_int0_isr(void) { delay_ms(10); inicio=on; OCR2=0xEF; buzzer=off; } // Rutina que apaga el proceso //sensor de nivel interrupt [EXT_INT1] void ext_int1_isr(void) { delay_ms(10); inicio=off; OCR2=0x00; alarma=on; nivel_bajo=on; inicio_proceso=off; buzzer=on; } // Timer 0 overflow interrupt service routine interrupt [TIM0_OVF] void timer0_ovf_isr(void) { TCNT0=0x16; //reinicia el timer if(inicio==1) { inicio_proceso=on; humidificador=on; nivel_bajo=off; ventilador=on; tiempo++; if (tiempo>=1000) { tiempo=0; humidificador=off; inicio=0; inicio_proceso=off;
OCR2=0x00; buzzer=on; } } } void main(void) { // Declare your local variables here DDRB=0xFF; // Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=O ut Func1=Out Func0=Out PORTB=0x00; // State7=0 State6=0 State5=0 State4=0 State3=0 State2=0 Sta te1=0 State0=0 // Port C initialization DDRC=0x00; // Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Fun c0=In PORTC=0x00; // State6=T State5=T State4=T State3=T State2=T State1=T Sta te0=T // Port D initialization DDRD=0x00; // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Fun c1=In Func0=In PORTD=0x0C; // State7=T State6=T State5=T State4=T State3=P State2=P Sta te1=T State0=T // Timer/Counter 0 initialization TCCR0=0x05; // Clock source: System Clock TCNT0=0x16; // Clock value: 7,813 kHz //Periodo de 29,952 // Timer/Counter 2 initialization // Clock source: System Clock // Clock value: 250,000 kHz // Mode: Fast PWM top=0xFF // OC2 output: Non-Inverted PWM // Timer Period: 1,024 ms // Output Pulse(s): // OC2 Period: 1,024 ms Width: 1,024 ms ASSR=0x00; TCCR2=0x6B; TCNT2=0x00; OCR2=0x00; // External Interrupt(s) initialization GICR|=0xC0; // INT0: On // INT0 Mode: Rising Edge MCUCR=0x0F; // INT1: On // INT1 Mode: Rising Edge GIFR=0xC0; TIMSK=0x01; #asm("sei") // Timer(s)/Counter(s) Interrupt(s) initialization // Global enable interrupts