// Remote control Coolpix shutter release. // A light sensor connected to SENSOR_3, an infrared lamp on OUT_C // The camera is triggered each time the beam of light is interrupted // Shutter release definitions #define ReleaseMotor OUT_A #define ReleaseTouch SENSOR_1 #define PressWait 5 #define PressedWait 5 #define ReleaseWait 15 #define IRlamp OUT_C #define LightDetect SENSOR_3 #define Threshold 5 #define DeadTime 300 task main() { int Ambient; int IRvalue; SetSensor(ReleaseTouch ,SENSOR_TOUCH); SetSensor(LightDetect ,SENSOR_LIGHT); while (true) { do { Ambient=LightDetect; OnFwd(IRlamp); Wait(5); IRvalue=LightDetect; Off(IRlamp); Wait(30); } while (IRvalue-Ambient > Threshold); PlaySound(0); // Shoot photo OnRev(ReleaseMotor); until (ReleaseTouch == 1); Wait(PressWait); Off(ReleaseMotor); Wait(PressedWait); OnFwd(ReleaseMotor); until (ReleaseTouch == 0); Wait(ReleaseWait); Off(ReleaseMotor); Wait(DeadTime); do { Ambient=LightDetect; OnFwd(IRlamp); Wait(5); IRvalue=LightDetect; Off(IRlamp); Wait(25); } while (IRvalue-Ambient < Threshold); } }