Hey everyone,
Right off the back: I'm a complete newbie to Arduino and circuits and have been playing with the stuff for about 5 days.
The attached file is a screenshot from Fritzing and it shows something I built to control a Canon 7D camera, 2 solenoid valves (represented by two red LEDs) and a Canon 580EXII flash. It will be used to take pics of water drops colliding. Code is at the end of this. I have used the Sparkfun inventors kit and its guide to get an understanding of the basics and the circuit I built is really just a small customization and joining of 2-3 of the example circuits. I admit I do not know whether all the parts on the board are needed or if this should be done another way. The idea here is this:
1. push a button: camera shutter opens (camera is in Bulb Mode) - I'm using a relay to control camera shutter, as the only thing needed to trigger the camera is shorting of pins.
2. specific amount of milliseconds later, open and close valve 1
3. same as #2 for valve 2
4. wait till the drops hit the surface
5. Trigger the flash - as with the camera trigger this is done by shorting pins. I'm using same way an LED would be lit up and turned off
6. Close the camera shutter
As it is currently built - it does the job, BUT... I read somewhere that I should protect the circuit from the flash using optoisolators. I have no idea how they work, but I'll figure that part out.
Here is the part where I need help and hopefully someone that's very experienced with circuits can just look at this and tell me what's going on in a few minutes.
Can you look at this, please, and tell me if any/all parts of this circuit are put together correctly? What is done wrong and how it can be corrected? Remember that this WORKS as is, but I understand that doesn't always mean its correct and should be used like this.
Any advice/help/comments would be appreciated!
Thanks,
Tom
const int button1Pin = 2; // pushbutton 1 pin
const int camerafocusPin = 6; // camera focus pin
const int camerashutterPin = 7; //camera shutter pin
const int valve1Pin = 9; //solenoid valve one
const int valve2Pin = 10; //solenoid valve two pin
const int flashPin = 11; //flash trigger pin
const int relayPin = 3; // use this pin to drive the transistor
const int timeDelay = 1000; // delay in ms for on and off phases
const int shutteropen = 8000; // delay in ms for on and off phases
void setup()
{
// Set up the pushbutton pins to be an input:
pinMode(button1Pin, INPUT);
pinMode(relayPin, OUTPUT); // set pin as an output
// Set up the LED pin to be an output:
pinMode (camerafocusPin, OUTPUT);
pinMode (camerashutterPin, OUTPUT);
pinMode (valve1Pin, OUTPUT);
pinMode (valve2Pin, OUTPUT);
pinMode (flashPin, OUTPUT);
}
void loop()
{
int button1State; // variables to hold the pushbutton states
button1State = digitalRead(button1Pin);
if (button1State == LOW) // if we're pushing button 1
{
digitalWrite(relayPin, LOW); // turn the relay on
delay(timeDelay); // wait for one second
digitalWrite (valve1Pin, HIGH); //open the first solenoid valve for 2 seconds
delay (100);
digitalWrite (valve1Pin, LOW);
delay (200); //delay between two valves
digitalWrite (valve2Pin, HIGH); //open the second solenoid valve for 1 seconds
delay (150);
digitalWrite (valve2Pin, LOW);
delay (200); // delay between the valve closing and drops actually hitting the water
digitalWrite (flashPin, HIGH); //fire the flash
delay (50);
digitalWrite (flashPin, LOW);
delay (300);
digitalWrite(relayPin, HIGH); // turn the relay off
delay (shutteropen);
}
else
{
digitalWrite(relayPin, HIGH); // turn the relay off
// shutter stays closed
}
}