X-Git-Url: http://www.average.org/gitweb/?p=sensor-light.git;a=blobdiff_plain;f=msp430%2Fmain.c;h=543022962a06b114721d3c7bb0cfadd34d40b06b;hp=9146b1836853084eb5540311cdacc71e91e32b04;hb=c289f198e917c6a6726e8ead0937a36662e3efff;hpb=166858d7fc9e861e6cc3dc75f5abd8d37c504659 diff --git a/msp430/main.c b/msp430/main.c index 9146b18..5430229 100644 --- a/msp430/main.c +++ b/msp430/main.c @@ -30,6 +30,7 @@ int main(void) int Increment = 1; unsigned int Time_Count = 0; unsigned int Time_Left = 5; + unsigned int Time_Indicate = 2; WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer // Configure GPIO Out @@ -107,13 +108,16 @@ int main(void) _enable_interrupts(); // Button 2 or PIR events initiate light measurement - // and tuns on green led + // and tuns on green or red led if (events & (1< 0) { Time_Left = TIME_ON; continue; } - P1OUT |= BIT_GL; // Set green LED on // Sampling and conversion start #ifdef ADCENC ADCCTL0 |= ADCENC | ADCSC; @@ -125,7 +129,8 @@ int main(void) // End of light measurement. Set new Duty_Cycle, // zero increment and turn off green led if (events & 1< PWM_HALF) { Time_Left = 0; Increment = -1; @@ -147,15 +154,18 @@ int main(void) // Timer event (100 ms) changed duty cycle and flashes red led if (events & 1< 20) { Time_Count = 0; - P1OUT |= BIT_RL; // red LED on if (Time_Left) Time_Left--; else if (Duty_Cycle > 1) Increment = -1; - } else if (Time_Count == 1) - P1OUT &= ~BIT_RL; // red LED off + } if (Increment > 0) { if (++Duty_Cycle >= PWM_ORDER) { Duty_Cycle = PWM_ORDER;