/*
LightBlue Shutter - Sandbox
Shutter Pin Connections:
FOCUS: 1
RELEA: 0
*/
/*************************************************************************/
/* Defines */
/*************************************************************************/
#define FOCUS_TIME_MS 400 //change here if your camera needs a longer or
#define RELEA_TIME_MS 300 //a shorter time to focus or to release
/*************************************************************************/
/* Pin Defines */
/*************************************************************************/
// Shutter Controller
int FOCUS = 0; //Focus
int RELEA = 1; //Release
/*************************************************************************/
/* Global Variables */
/*************************************************************************/
void setup(){
Serial.begin(57600);
Serial.setTimeout(25);
// Shutter Setup
pinMode(FOCUS, OUTPUT);
digitalWrite(FOCUS,LOW);
pinMode(RELEA, OUTPUT);
digitalWrite(RELEA,LOW);
}
/*************************************************************************/
/* Main Loop */
/*************************************************************************/
void loop(){
char buffer[10];
size_t length = 2;
buffer[0] = 0;
length = Serial.readBytes(buffer, length);
if( length > 1 ){
if( (buffer[0] == 13) && (buffer[1] == 0) ){
focus(); //focus
}
if( (buffer[0] == 14) && (buffer[1] == 0) ){
relea(); //release
}
}
Bean.sleep(0xFFFFFFFF); // Sleep until a serial message wakes us up
}
/*************************************************************************/
/* Focus function */
/*************************************************************************/
void focus(void){
digitalWrite(FOCUS, HIGH); //focus
Bean.setLed(255,0,0); //turn on LED (red)
delay(FOCUS_TIME_MS);
digitalWrite(FOCUS, LOW); //focus stop
Bean.setLed(0,0,0); //turn off LED
}
/*************************************************************************/
/* Release function */
/*************************************************************************/
void relea(void){
digitalWrite(RELEA, HIGH); //release
Bean.setLed(0,255,0); //turn on LED (green)
delay(RELEA_TIME_MS);
digitalWrite(RELEA, LOW); //release stop
Bean.setLed(0,0,0); //turn off LED
}
/*************************************************************************/
Comments