The solenoid is for water droplet photos. Activation is via push button, a pot will determine the timing between droplets. with the pot all the way 1 way, only 1 pulse is perceived,(it is actually 2 but only 1 is perceived) turning it to the left give it a double pulse, and sets timing between pulses. Another device controls the camera and flash's, and is working fine.
Pot is connected to pin A2, 5v, and g. L.E.D. is to pin 9 and g, and pin 4 is set to fire solenoid. A push button at pin 5.
The solenoid and PSU is what I have, and I wanted to keep my costs down. The Opto is not blown. But I thought I would just give it a try, and if it did not work, then use an N-Channel MOSFET, ON Semi NTD9463N-1G to fire the solenoid. The ROHMBA07CC0T, and ON Semi NTD9463N-1G are still in the mail, I don't have them yet. I will wire up the BA07CC0T per your instructions, then wire the ON Semi as: Source pin to Gnd on psu and arduino gnd, The Gate of MOSFET, to arduino pin 4 with a 200Ω resistor, The 18v to the Drain pin of the MOSFET. Nothing is set in stone, and I am very open to suggestions and help. I know you said the PSU was ??? but I would like to use it if at all possible.
I do appreciate the help you have given me. It is valuable, and I will use it, and learn.
Steve
Here is the sketch I am using:
/*
* Pushing a button
* turns on and off a light emitting diode(LED) connected to digital
* pin 9 and solenoid valve on pin 4. The amount of time the between
* LED blinks on and off depends on delay value, and
* the value obtained by analogRead() from a potentiometer at pin 2.
*
*
*
*/
#define BUTTON_PIN 5
#define VALVE
#define STANDBY 0
#define ACTIVE 1
int potPin = 2; // select the input pin for the potentiometer
int ledPin = 9; // select the pin for the LED
int valve = 4; // select the pin for the valve
int val = 0; // variable value coming from the pot
int mode = STANDBY;
void setup() {
pinMode(BUTTON_PIN, INPUT);
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
pinMode(valve, OUTPUT);
}
void loop() {
if (digitalRead(BUTTON_PIN) == HIGH)
{
mode = ACTIVE;
delay(750); // delay after button is pushed
val = analogRead(potPin); // read the value from the sensor this command can be removed
digitalWrite(ledPin, HIGH); // turn on LED
digitalWrite(valve, HIGH); // open valve
delay(10); // adjust to keep valve open for droplet size
digitalWrite(ledPin, LOW); // turn the LED off
digitalWrite(valve, LOW); // close valve
delay(val); // stop the program for delay value
val = analogRead(potPin); // read the value from the sensor
digitalWrite(ledPin, HIGH); // turn on LED
digitalWrite(valve, HIGH); // open valve for second droplet
delay(10); // adjust to keep valve open for droplet size
digitalWrite(ledPin, LOW); // turn the valve off
digitalWrite(valve, LOW); // close valve
delay(1000); // stop the program for delay value
}
}