Ciao, avrei bisogno di una mano per un progettino.
Dovrei effettuare delle foto macro, con l’attivazione dello scatto tramite il suono, l’interruzione di un fascio di luce, oppure ogni tot tempo.
In rete ho trovato 2 programmi che fanno il caso mio.
Il primo fa chiudere il contatto (flash) all’interruzione del fascio o al captare del suono, il secondo invece, invia tramite infrarosso il treno di impulsi che la macchina fotografica interpreta come scatto (Nikon)
La mia richiesta è quella di poter accorpare i 2 programmi, in modo che all’accadere di un evento, mi chiuda il contatto e mi attivi l’infrarosso in modo che mi faccia scattare la macchina.
primo programma
//#define ENABLE_LASER_TRIGGER
#define ENABLE_SOUND_TRIGGER
// The threshhold values for the different triggers.
// These may need to be changed depending on evironment and sensors being used.
// Using PRINT_MESSAGES can help determine the correct value for these.
#define LASER_THRESHHOLD 500
#define SOUND_THRESHHOLD 100
// This prints messages to the serial port. This is good to enable while determining
// the threshholds for your trigger, but these communications are very slow and
// when using these sensors to actually take pictures this should be turned off.
//#define PRINT_MESSAGES
// The digital pins being used
#define CAMERA_FLASH_PIN 4
#define LASER_PIN 5
// The analog pins being used
#define LASER_TRIGGER_ANALOG_PIN 0
#define SOUND_TRIGGER_ANALOG_PIN 1
void setup()
{
pinMode(CAMERA_FLASH_PIN, OUTPUT);
digitalWrite(CAMERA_FLASH_PIN, LOW);
pinMode(LASER_PIN, OUTPUT);
digitalWrite(LASER_PIN, LOW);
#ifdef ENABLE_LASER_TRIGGER
digitalWrite(LASER_PIN, HIGH); // Turn on the Laser
#endif
#ifdef PRINT_MESSAGES
Serial.begin(9600); // open serial
#endif
}
void loop()
{
int soundVal;
int laserVal;
////////////////////////////////////////////////////////////
// SOUND TRIGGER
////////////////////////////////////////////////////////////
#ifdef ENABLE_SOUND_TRIGGER
soundVal = analogRead(SOUND_TRIGGER_ANALOG_PIN);
if (soundVal > SOUND_THRESHHOLD)
{
digitalWrite(CAMERA_FLASH_PIN, HIGH);
#ifdef PRINT_MESSAGES
Serial.println(“Flash Triggered!!!”);
#endif
delay(100);
digitalWrite(CAMERA_FLASH_PIN, LOW);
}
#ifdef PRINT_MESSAGES
Serial.print("Sound: ");
Serial.println(soundVal, DEC);
#endif
#endif // ENABLE_SOUND_TRIGGER
////////////////////////////////////////////////////////////
// LASER TRIGGER
////////////////////////////////////////////////////////////
#ifdef ENABLE_LASER_TRIGGER
laserVal = analogRead(LASER_TRIGGER_ANALOG_PIN);
if (laserVal < LASER_THRESHHOLD)
{
digitalWrite(CAMERA_FLASH_PIN, HIGH);
digitalWrite(LASER_PIN, LOW); // Turn off laser during picture
#ifdef PRINT_MESSAGES
Serial.println(“Flash Triggered!!!”);
#endif
delay(100);
digitalWrite(CAMERA_FLASH_PIN, LOW);
digitalWrite(LASER_PIN, HIGH); // Turn laser back on after picture
}
#ifdef PRINT_MESSAGES
Serial.print("Laser: ");
Serial.println(laserVal, DEC);
#endif
#endif // ENABLE_LASER_TRIGGER
}
Secondo programma
int pinIRLED = 13; // Assegnazione Pin Diodo Infrarosso
void setup() {
pinMode(pinIRLED, OUTPUT); // Assegnazione Pin in Uscita
}
// sets the pulse of the IR signal.
void pulseON(int pulseTime) {
unsigned long endPulse = micros() + pulseTime; // create the microseconds to pulse for
while( micros() < endPulse) {
digitalWrite(pinIRLED, HIGH); // Accende Diodo Infrarosso
delayMicroseconds(13); // half the clock cycle for 38Khz (26.32×10-6s) - e.g. the ‘on’ part of our wave
digitalWrite(pinIRLED, LOW); // Spenge Diodo Infrarosso
delayMicroseconds(13); // delay for the other half of the cycle to generate wave/ oscillation
}
}
void pulseOFF(unsigned long startDelay) {
unsigned long endDelay = micros() + startDelay; // create the microseconds to delay for
while(micros() < endDelay);
}
void takePicture() {
for (int i=0; i < 2; i++) {
pulseON(2000); // pulse for 2000 uS (Microseconds)
pulseOFF(27850); // turn pulse off for 27850 us
pulseON(390); // and so on
pulseOFF(1580);
pulseON(410);
pulseOFF(3580);
pulseON(400);
pulseOFF(63200);
} // loop the signal twice.
}
void loop() {
takePicture(); // Scatto foto
delay(5000); // Ritardo scatto foto da 1 a 1000 secondi
}
Di seguito il link dello schema elettrico
http://www.modellismofirenze.com/images/stories/Nikon.jpg
Spero di essermi spiegato
Ringrazio anticipatamente