Arduino Drop programing.

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

You defined delayvalue and assigned it with 0, but later in your program you didn't assign any meaningful values to it. You defined sensorvalue and assigned the potentiometer analog reading to it, but didn't use this value anywhere.

If you can answer this two questions (why you did above), you may be able to modify your program to do what you want it to do.

please use "#" button to include your code.

Thanks for the answer.

First i had a sensor to regulate the interval but then i abandoned it. Just left it in the code i gess.

hum....How can i modify?

You need to assign a value to the delayvalue. At the moment it is assigned with 0, so there won't be any delay. I think what you can do is to use a potentiometer to adjust delay and DISPLAY the delay value on an LCD so you know what delay you are using before you push the button to start the process. Did that make some sense to you?

Please use this button, in red square, to insert code. modify your post.

Ive changed the post...sorry :P

What delay do you mean?

The one with "delayvalue" as an argument?