Hi all.
I am making a Arduino based Water droper for my Photos.
Currently i am using this code.
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
const int FlashPin = 11; // the number of the flash pin
int sensorPin = A0; // select the input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the flash pin as an output:
pinMode(FlashPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
sensorValue = analogRead(sensorPin);
digitalWrite(ledPin, HIGH);
delay(20);
digitalWrite(ledPin, LOW);
delay(130);
digitalWrite(ledPin, HIGH);
delay(20);
digitalWrite(ledPin, LOW);
delay(295);
digitalWrite(FlashPin, HIGH);
delay(5);
digitalWrite(FlashPin, LOW);
delay(50);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
It Runs a simple program that goes through the steps with delays. The problem i have is that i have to be constently changing the output time for the flash each time i change the drop dellay.
I wanted to do something that allows me to have separete times for the Valve and for the flashes. So that when i change the timing ons the drops the timing on the flash dont change and keep on the impact.
I have made this but i dont know if it works couse i know almost nothing of programing
#define DEFAULTFLASHDELAY 500
// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin
const int FlashPin = 11; // the number of the flash pin
int delayValue = DEFAULTFLASHDELAY; // Flash delay
int sensorPin = A0; // select the input pin for the potentiometer
int sensorValue = 0; // variable to store the value coming from the sensor
int buttonState = 0; // variable for reading the pushbutton status
void dischargeFlash() {
// Discharge the flash with a 10ms pulse to the opto-isolator...
digitalWrite(FlashPin, HIGH);
delay(10);
digitalWrite(FlashPin, LOW);
}
void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the flash pin as an output:
pinMode(FlashPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
delay(delayValue);
dischargeFlash();
sensorValue = analogRead(sensorPin);
digitalWrite(ledPin, HIGH);
delay(20);
digitalWrite(ledPin, LOW);
delay(130);
digitalWrite(ledPin, HIGH);
delay(20);
digitalWrite(ledPin, LOW);
delay(50);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}
Does this let me change the flash dellay do 500 independant of the droplet timing?
I dont know if i made my self clear. Any help is much appreciated
Best regards