int main(int argc,char **argv) { PetscMPIInt size; PetscErrorCode ierr; PetscInitialize(&argc,&argv,(char *)0,help); ierr = MPI_Comm_size(PETSC_COMM_WORLD,&size); CHKERRQ(ierr); if (size != 1) SETERRQ(PETSC_COMM_WORLD, 1,"This is a uniprocessor example only!"); ierr = assembled_system(); CHKERRQ(ierr); ierr = block_system(); CHKERRQ(ierr); ierr = PetscFinalize(); CHKERRQ(ierr); return 0; }
/** Function Start*/ int main(void) { /** Define PortB as an output*/ DDRB = DDRB & 0b00101111; /** Define PortE as an output*/ DDRE = DDRE & 0b11101100; PORTB = PORTB | 0b11010111; PORTE = PORTE | 0b11101100; /**Start LCD*/ LCD_Init(); // ADC_init(0b00100000); ADCSRA = (1<<ADEN); DDRF=0; /**Declares an array of 3 int values*/ int value[3]; /**Declares int variables*/ int a,b,c,error,v, cont; error=0; /**First value of the password*/ a=3; /**Second value of the password*/ b=3; /**Third value of the password*/ c=3; /**Declare three double password*/ double T1, T0, cont1; DDRD = 255; while(1) { /** Welcome message*/ LCD_TEXT("WELCOME") /** Delay*/ _delay_ms(2000); /**CLear the LCD*/ CLEAR_LCD /**Introduce your password*/ LCD_TEXT("PASSWORD") /** Nose */ while(PINB & (1 << 7)); while(!(PINB & (1 << 7))); /**Password data loop */ for (int i=0; i<3; i++) { while(PINB & (1 << 7)) { /**Call the function pasword_value to obtain the data*/ v=password_value (); LCD_NUMBER(v) _delay_ms(200); } while(!(PINB & (1 << 7))); /**Store data in value array*/ value[i]=password_value (); } /**Check the password values introduced*/ if (value[0]==a && value[1]==b && value[2]==c) { CLEAR_LCD LCD_TEXT("OK") _delay_ms(2000); /**Obtain the first temperature value */ T0=temperature(); /**Turn the light on, open the door PORTB0 */ sbi(PORTB,0); cont1=cont=0; while (PORTB & 0b00000001) { /**Call the function counter */ cont=counter(cont); /**Check the counter */ if(cont==1) { /**Obtain the actual temperature in the security box */ T1=temperature(); LCD_TEXT("TEMP") _delay_ms(800); LCD_NUMBER(T1) /**Conditional to control temperature*/ if(T1>T0) /**Temperature to high Turn cooler on */ sbi(PORTB,1); else /**Temperature ok the cooler is off */ cbi(PORTB,1); _delay_ms(800); cont1=0; } /**Conditional to activate the alarm*/ if(cont>1) { /**Turn alarm on */ sbi(PORTB,2); LCD_TEXT("ALARM") cbi(PORTB,0); _delay_ms(1000); /**Call the function block systen */ block_system(); } if(cont<=0) { if(cont1<10000) { cont1++; } else { LCD_TEXT("Exit") _delay_ms(500); /**Turn off light and close the door */ cbi(PORTB,0); } } } }