#include "moje_lib.h" #include "msp430g2231.h" #define LED1 BIT0 #define LED2 BIT6 #define S2 BIT3 #define SENS BIT5 #define SIRE BIT7 #define DEL1 5000 #define DEL2 50000 void main(void) { WDTCTL = WDTPW + WDTHOLD; P1DIR |= (LED1 + LED2 + SIRE); P1OUT &= ~(LED1 + LED2 + SIRE); for (;;) { unsigned int y; unsigned int z; while ((P1IN & SENS) == SENS) { P1OUT ^= LED2; delaytime(DEL1); } while ((P1IN & SENS) != SENS) { P1OUT |= LED2; delaytime(DEL2); } for (y = 30; y > 0; y--) { P1OUT ^= LED2; P1OUT ^= LED1; delaytime(DEL2); if ((P1IN & S2) != S2) z = 1; else z = 0; } if (z == 0) { P1OUT &= ~LED2; P1OUT |= (LED1 + SIRE); for (y = 200; y > 0; y--) { delaytime(DEL2); P1OUT ^= LED1; delaytime(DEL1); P1OUT ^= LED1; } P1OUT &= ~(LED1 + SIRE); } } }