MAQUINA DE LAVAR#include <lpc213x.h> //incluindo bibliotecas#include "c:\Keil\ARM\3_LCD 2X 16\lcd.h" //#include <stdio.h> sao arquivos-texto #define liga_desliga (1<<20) //in#define admisao_agua (1<<16)//out#define enxurpo_agua (1<<17) //out #define sensor_porta (1<<22) //in //DECLARANDO AS VARIAVEIS#define sensor_nivel (1<<21) //in #define motor_direita (1<<18) //out //DECLARANDO AS VARIAVEIS#define motor_esquerda (1<<19) //#define led (1<<21)int tempo1 (int limite) // declarando as variaveis antes de utiliza-las{int t;0; //declara variavel local t inteirafor (t=0;t<limite;t++); //loop for inicia t=0 compara com o limite definido}/****************************************************************************** EINT0 interrupt service function******************************************************************************/__irq void EINT0_IRQHandler(void) {IOSET1= (led); lcd_clr();lcd_gotoxy(0,2);lcd_puts(" tampa aberta");IOCLR1= (enxurpo_agua);IOCLR1= (admisao_agua);IOCLR1= (motor_esquerda);IOCLR1= (motor_direita);EXTINT = 1; /* Clear EINT0 interrupt flag */VICVectAddr = 0; /* Acknowledge Interrupt */}/****************************************************************************** EINT1 interrupt service function******************************************************************************/__irq void EINT1_IRQHandler(void) {EXTINT = 2; /* Clear EINT1 interrupt flag */VICVectAddr = 0; /* Acknowledge Interrupt */}/* Default Interrupt Function: may be called when ISR is disabled */__irq void DefISR (void) {}int tempo (){int t;for(t=0;t<10;t++);}int main(void){/* P0.0: PORT0.0 (General purpose I/O) Output P0.14: EINT1 (External interrupt 1 input) P0.16: EINT0 (External interrupt 0 input)*/PINSEL0=0x20000000; // binary: 00100000_00000000_00000000_00000000PINSEL1=0x00000001;// binary: 00000000_00000000_00000000_00000001PINSEL2=0x00000000;// binary: 00000000_00000000_00000000_00000000IODIR0 = 0xFFFCFFFF; //definindo bits de entrada e saidaIODIR1 = 0xFF8FFFFF;init_lcd ();/****************************************************************************** External interrupts******************************************************************************* Ext. interrupt 0 mode: LEVEL sensitivity / low Ext. interrupt 1 mode: LEVEL sensitivity / low*/EXTMODE=0x00; /* binary: 00000000 */EXTPOLAR=0x00; /* binary: 00000011 */INTWAKE = ( INTWAKE & 0xC00F ) | 0x0000;//binary: 00000000_00000000EXTINT=0x03; // clear the external interrupt flags/****************************************************************************** Vector interrupt initialization******************************************************************************/ VICVectAddr0 = (unsigned long) EINT0_IRQHandler; //set interrupt vector 0 VICVectCntl0 = ( 0x20 | 14 ); //enable slot & use it for EINT0 Interrupt VICIntEnable |= ((unsigned long)1<<14); // Enable EINT0 Interrupt VICVectAddr1 = (unsigned long) EINT1_IRQHandler;//set interrupt vector 1 VICVectCntl1 = ( 0x20 | 15 ); //enable slot & use it for EINT1 Interrupt VICIntEnable |= ((unsigned long)1<<15); // Enable EINT1 Interrupt VICDefVectAddr = (unsigned long) DefISR;//un-assigned VIC interrupts while(1){if (IOPIN0 & (liga_desliga)) {IOCLR1= (led);IOCLR1 = (admisao_agua); lcd_clr();lcd_puts(" ligar a maquina");}else {if (!(IOPIN1 & (sensor_nivel))){IOCLR1= (led);IOSET1=(admisao_agua);lcd_clr();lcd_puts(" admitindo agua");}else{IOCLR1= (led); IOCLR1=(admisao_agua);lcd_clr();lcd_puts(" lavando");while(1) { int i;0; for (i=0;i<3;i++) {IOCLR1= (led);IOSET1= (motor_direita);tempo1(300); IOCLR1= (motor_direita); IOSET1= (motor_esquerda);tempo1(300); IOCLR1= (motor_esquerda); i++;}if (IOPIN1 & (sensor_nivel)){IOSET1= (enxurpo_agua); } while (((IOPIN1 & (sensor_nivel)))) {IOCLR1= (led);lcd_clr();lcd_puts(" enxaguando"); }while(1) {if (!(IOPIN1 & (sensor_nivel))) {IOCLR1= (led);IOCLR1= (enxurpo_agua); //desliga enxurpoIOSET1=(admisao_agua);lcd_clr();lcd_puts(" admitindo agua"); } while (1) //nova condicao{ if (IOPIN1 & (sensor_nivel)) //consulta sensor nivel{IOCLR1= (led);IOCLR1= ( admisao_agua); //desliga admissao de agualcd_clr();lcd_puts("CENTRIFUGANDO");IOSET1= (enxurpo_agua); //liga enxurpoIOSET1= (motor_direita); //liga motorIOSET1= (motor_esquerda);tempo1(200); //definido tempoIOCLR1= (enxurpo_agua);IOCLR1= (motor_direita); //desligandoIOCLR1= (motor_esquerda);while(1){IOCLR1= (led);lcd_clr();lcd_puts(" FIM DE CICLO"); while (1); //fim do ciclo} } } } } } } } } RESPIRADOR #include <lpc21xx.h>#include "c:\Keil\ARM\lcd.h"//definindo entradas IODIR1#define motor (1<<20)#define rele (1<<23)#define pressao (1<<21)//definindo saidas IODIR0#define interrupcao (1<<27)#define parada10 (1<<16)#define parada20 (1<<17)#define parada30 (1<<18)#define led (1<<19)unsigned int val;int i;int tempo (void) {int x;for (x=0; x<100;x++); }/****************************************************************************************************************************************** FUNCAO PORTA ABERTA INTERRUPCAO*******************************************************************************************************************************************/ int atualiza (void){ if(val<937) // Pressao 200 = 2,61V/3,2V(10^-3) = Val=812 /// Res= FEa/FEd= 3,3V/1023= 3,2mV { IOSET0 = (1<<19); IOSET1 = (1<<23); } else { IOCLR0 = (1<<19); IOCLR1 = (1<<23);//init_lcd(); IOCLR0 = (pressao); lcd_clr();lcd_gotoxy(0,0); lcd_puts("PRESSAO MAXIMA ");lcd_gotoxy(1,0);lcd_puts(" ALERTA "); lcd_gotoxy(1,0); tempo();lcd_puts("PAC.MORRRENDO"); tempo(); atualiza(); }} int main (void) { IODIR0 = 0x0; IODIR1 = 0xFFF8FFFF; PINSEL1 = 0X400001; VPBDIV = 0x02; /*Setando Pclk = 30 Mhz */ ADCR = 0x00210601; while (1) { init_lcd();