Blackfin:
Try:
//#define DEV 1 //for dev
#ifndef DEV
const int ledPin = LED_BUILTIN;// the number of the LED pin
#else
const int ledPin = 0;// the number of the LED pin
#endif
const int analogPin = A0; // pin that the Solar panel is attached to
const int threshold = 90; // The threshold level that is between the solar value readings when the laser is in contact vs when the laser is off.
// change threshold value to calabrate alarm system
const int ledAlarm = 6;
#define SAMPLE_INTERVAL 500
#define ALARM_TOGGLE 250
#define LOW_THRESH_FLG 0b00000001
#define ALARM_STATE 0b00000010
#define TAKE_SAMPLE_FLG 0b00000100
byte
bFlags;
// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long
currentTime,
last_AlarmTime,
last_SampleTime;
void setup() {
// set the digital pin as output:
pinMode(ledPin, OUTPUT);
pinMode(ledAlarm, OUTPUT);
// initialize serial communications:
Serial.begin(9600);
while( !Serial ); //wait for console
currentTime = millis();
last_AlarmTime = currentTime;
last_SampleTime = currentTime;
bFlags = 0b00000000;
}
void loop()
{
//Serial.println(bFlags);
Channel_Read();
GeneralTimerUpdates();
Output_Handler();
}//loop
void Channel_Read()
{
int
analogValue;
if( !(bFlags & TAKE_SAMPLE_FLG) )
return;
//if flag is already set, just leave
if( bFlags & LOW_THRESH_FLG )
return;
#ifndef DEV
analogValue = analogRead(analogPin);
#else
analogValue = 80; //test value
#endif
if( analogValue < threshold )
bFlags |= LOW_THRESH_FLG;
bFlags &= ~TAKE_SAMPLE_FLG;
}//Channel_Read
void GeneralTimerUpdates()
{
currentTime = millis();
//sample timer
if( (currentTime - last_SampleTime) >= SAMPLE_INTERVAL )
{
bFlags |= TAKE_SAMPLE_FLG;
last_SampleTime = currentTime;
}//if
//alarm timer
if( (currentTime - last_AlarmTime) >= ALARM_TOGGLE )
{
//toggle ALARM flag in bFlags; alarm output will track it
//if input is < threshold
bFlags ^= ALARM_STATE;
last_AlarmTime = currentTime;
}//if
}//GeneralTimerUpdates
void Output_Handler()
{
//if below threshold, alarm tracks ALARM_STATE bit
//otherwise it's off
//assumes HIGH turns on alarm
digitalWrite( ledAlarm, (bFlags & LOW_THRESH_FLG) ? ((bFlags & ALARM_STATE)?HIGH:LOW):LOW );
//if below threshold, LED is on solid
//otherwise it's off
//assumes HIGH turns on LED
digitalWrite( ledPin, (bFlags & LOW_THRESH_FLG) ? HIGH:LOW );
}//Output_Handler
That worked 
Now I need to pay close attention to what you did and learn from it.
Thank you all...thx Blackfin