Arduino Uno Water Drop Controller

Howdy folks,

I finally got my water drop controller doing what I want it to do.

The scope of the project is to control a ssolenoid valve that will allow one, two, or
three drops of liquid to fall into a tray so that I can take a picture of the drops hitting the
surface of the tray and also photograph a drop colliding with the column of liquid thrown
up by a previous drop. The controller allows me to select a drop stream and control the
spacing between drops. It seems to do everything that I want it to do.

OOOOOOPPPPPPSSSSSS! The code is to large to load. Looks like I need to split it between a couple of posts.

Tomorrows project.

Link to You Tube for a video showing what the controller does.

RWW

#include <LiquidCrystal.h>
#include <EEPROM.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

/*
 Right        Value = 0
 Up           Value = 1
 Down         Value = 2
 Left         Value = 3
 Select       Value = 4
 */
int  adc_key_val[5] ={
  30, 150, 360, 535, 760 };

int NUM_KEYS = 5;
int adc_key_in;
int key=-1;
int oldkey=-1;

int lcdTopRow = 0;
int lcdBottomRow = 1;
int DropCount = 0;       // default Starting point
int pulseWidth0 = 0;    //Valve ON Time  (Drop Size)
int pulseWidth1 = 0;    //Valve ON Time  (Drop Size)
int pulseWidth2 = 0;    //Valve ON Time  (Drop Size)
int pulseSep0 = 0;      // Drop Seperation time  (Time Between Drops), valve off time
int pulseSep1 = 0;      // Drop Seperation time  (Time Between Drops), valve off time

int reading = 0;

int VLVOFF = LOW;
int VLVON = HIGH;
int backLightON = HIGH;
int backLightOFF = LOW;
int ledpinON = HIGH;
int ledpinOFF = LOW;
int triggerON = LOW;
int triggerOFF = HIGH;
int dropsAwayON = LOW;
int dropsAwayOFF = HIGH;
int backLightControl = 10;   // Output to control back light on LCD
int valveControl =11;    // Output pin to turn valve ON & OFF
int ledpin = 13;         // Heartbeat indicator
int timerTrigger = 2;    // Output pin to start flash trigger timer
int dropsAway = 3;       // Output pin to show signal to valve
int cursorValue = 0;

void setup() 
{ 
  pinMode(timerTrigger,OUTPUT);   //flash timer trigger
  pinMode(backLightControl,OUTPUT);   //Backlight control
  pinMode(valveControl,OUTPUT);   //valve control
  pinMode(ledpin, OUTPUT);  //we'll use the debug LED to output a heartbeat
  pinMode(dropsAway,OUTPUT);      // indicater for valve signal

  lcd.begin(16,2);
  Serial.begin(9600);

  //load our variables from EEPROM
  DropCount = EEPROM.read(0);
  pulseWidth0 = EEPROM.read(1);
  pulseSep0 = EEPROM.read(2);
  pulseWidth1 = EEPROM.read(3);
  pulseSep1 = EEPROM.read(4);
  pulseWidth2 = EEPROM.read(5);

  digitalWrite(dropsAway,dropsAwayOFF);          // Turn off the indicator
  digitalWrite(valveControl,VLVOFF);             // Valve OFF
  digitalWrite(ledpin, ledpinOFF);               // Turn OFF board LED
  digitalWrite(backLightControl,backLightON);    // Turn ON LCD Backlight
  lcd.clear();


  if (DropCount == 1)
  {
    lcd.setCursor(0,lcdTopRow);
    lcd.print("Drop Count");
    lcd.setCursor(0,lcdBottomRow);
    lcd.print(DropCount);
    lcd.print(" ");
    lcd.print(pulseWidth0);
  }

  else if (DropCount == 2)
  {
    lcd.setCursor(0,lcdTopRow);
    lcd.print("Drop Count");
    lcd.setCursor(0,lcdBottomRow);
    lcd.print(DropCount);
    lcd.print(" ");
    lcd.print(pulseWidth0);
    lcd.print(" ");
    lcd.print(pulseSep0);
    lcd.print(" ");
    lcd.print(pulseWidth1);
  }

  else if (DropCount == 3)
  {
    lcd.setCursor(0,lcdTopRow);
    lcd.print("Drop Count");
    lcd.setCursor(0,lcdBottomRow);
    lcd.print(DropCount);
    lcd.print(" ");
    lcd.print(pulseWidth0);
    lcd.print(" ");
    lcd.print(pulseSep0);
    lcd.print(" ");
    lcd.print(pulseWidth1);
    lcd.print(" ");
    lcd.print(pulseSep1);
    lcd.print(" ");
    lcd.print(pulseWidth2);
  }
  lcd.setCursor(0,lcdBottomRow);
  lcd.cursor();   //Turn on the cursor
}

void loop() 
{

  adc_key_in = analogRead(0);    // read the value from the sensor  

  key = get_key(adc_key_in);    // convert into key press
  if (key != oldkey) // if keypress is detected
  {
    delay(50);      // wait for debounce time
    adc_key_in = analogRead(0);    // read the value from the sensor  
    key = get_key(adc_key_in);    // convert into key press
    if (key != oldkey)             
    {           
      oldkey = key;
      if (key >=0)     
      {
        rightkey();
      }
      if (key == 1)     //up key
      {
        upkey();

      }

      else if (key == 2)   //down  key
      {
        downkey();

      }
      else if (key ==3)    //left key

      {
        leftkey();
      }

      else if (key == 4)     //select key
      { 
        outloop();
        delay(500);
      }
    }
  }    
}




// Convert ADC value to key number

int get_key(unsigned int input)
{   
  int k;
  for (k = 0; k < NUM_KEYS; k++)
  {
    if (input < adc_key_val[k])
    {  
      return k;  
    }
  }
  if (k >= NUM_KEYS)
    k = -1;     // No valid key pressed
  return k;
}
/*

 
 
 
 
 
 */
void rightkey()
{


  if (key == 0)    //right key
  {
    cursorValue++;
    if (cursorValue >= 15)
    {
      cursorValue = 15;
    }

    lcd.setCursor (cursorValue,1);
    //lcd.print (cursorValue);

    if (cursorValue == 2 && DropCount == 3)
    {

      lcd.setCursor(0,lcdTopRow);
      lcd.print("                ");
      lcd.setCursor(0,lcdTopRow);
      lcd.print("Drop 1 Size");
      lcd.setCursor(cursorValue,1);
    }
    // lcd.print(pulseWidth0);

    else if (cursorValue == 5 && DropCount == 3)
    {
      lcd.setCursor(0,lcdTopRow);
      lcd.print("Drop 1 & 2 Sep");
      lcd.setCursor(cursorValue,1);
    }

    else if (cursorValue == 8 && DropCount == 3)
    {
      lcd.setCursor(0,lcdTopRow);
      lcd.print("               ");
      lcd.setCursor(0,lcdTopRow);
      lcd.print("Drop 2 Size");
      lcd.setCursor(cursorValue,1);
    }
    else if (cursorValue == 11 && DropCount == 3)
    {
      lcd.setCursor(0,lcdTopRow);

      lcd.print("Drop 2 & 3 Sep");
      lcd.setCursor(cursorValue,1);
    }
    else if (cursorValue == 14 && DropCount == 3)
    {
      lcd.setCursor(0,lcdTopRow);
      lcd.print("               ");
      lcd.setCursor(0,lcdTopRow);
      lcd.print("Drop 3 Size");
      lcd.setCursor(cursorValue,1);

    }
    if (cursorValue == 2 && DropCount == 2)
    {
      lcd.setCursor(0,lcdTopRow);
      lcd.print("                ");
      lcd.setCursor(0,lcdTopRow);
      lcd.print("Drop 1 Size");
      lcd.setCursor(cursorValue,1);
    }


    else if (cursorValue == 5 && DropCount == 2)
    {
      lcd.setCursor(0,lcdTopRow);
      lcd.print("Drop 1 & 2 Sep");
      lcd.setCursor(cursorValue,1);
    }

    else if (cursorValue == 8 && DropCount == 2)
    {
      lcd.setCursor(0,lcdTopRow);
      lcd.print("               ");
      lcd.setCursor(0,lcdTopRow);
      lcd.print("Drop 2 Size");
      lcd.setCursor(cursorValue,1);
    }
    else if (cursorValue == 2 && DropCount == 1)
    {
      lcd.setCursor(0,lcdTopRow);
      lcd.print("                ");
      lcd.setCursor(0,lcdTopRow);
      lcd.print("Drop 1 Size");
      lcd.setCursor(cursorValue,1);
    }
  }  
} 
/*

More of the code:

 */
void leftkey()
{
  cursorValue--;
  if (cursorValue <= 0)
  {
    cursorValue = 0;
  }  
  lcd.setCursor (cursorValue,1);

  if (cursorValue == 0)
  {
    lcd.setCursor(0,lcdTopRow);
    lcd.print("                ");
    lcd.setCursor(0,lcdTopRow);
    lcd.print ("Drop Count");
    lcd.setCursor(cursorValue,1);
  }
  if (cursorValue == 2 && DropCount == 3)
  {

    lcd.setCursor(0,lcdTopRow);
    lcd.print("                ");
    lcd.setCursor(0,lcdTopRow);
    lcd.print("Drop 1 Size");
    lcd.setCursor(cursorValue,1);
  }

  else if (cursorValue == 5 && DropCount == 3)
  {
    lcd.setCursor(0,lcdTopRow);
    lcd.print("Drop 1 & 2 Sep");
    lcd.setCursor(cursorValue,1);
  }

  else if (cursorValue == 8 && DropCount == 3)
  {
    lcd.setCursor(0,lcdTopRow);
    lcd.print("               ");
    lcd.setCursor(0,lcdTopRow);
    lcd.print("Drop 2 Size");
    lcd.setCursor(cursorValue,1);
  }
  else if (cursorValue == 11 && DropCount == 3)
  {
    lcd.setCursor(0,lcdTopRow);

    lcd.print("Drop 2 & 3 Sep");
    lcd.setCursor(cursorValue,1);
  }
  else if (cursorValue == 14 && DropCount == 3)
  {
    lcd.setCursor(0,lcdTopRow);
    lcd.print("               ");
    lcd.setCursor(0,lcdTopRow);
    lcd.print("Drop 3 Size");
    lcd.setCursor(cursorValue,1);              
  }

  if (cursorValue == 2 && DropCount == 2)
  {
    lcd.setCursor(0,lcdTopRow);
    lcd.print("                ");
    lcd.setCursor(0,lcdTopRow);
    lcd.print("Drop 1 Size");
    lcd.setCursor(cursorValue,1);
  }
  // lcd.print(pulseWidth0);

  else if (cursorValue == 5 && DropCount == 2)
  {
    lcd.setCursor(0,lcdTopRow);
    lcd.print("Drop 1 & 2 Sep");
    lcd.setCursor(cursorValue,1);
  }

  else if (cursorValue == 8 && DropCount == 2)
  {
    lcd.setCursor(0,lcdTopRow);
    lcd.print("               ");
    lcd.setCursor(0,lcdTopRow);
    lcd.print("Drop 2 Size");
    lcd.setCursor(cursorValue,1);
  }
  if (cursorValue == 2 && DropCount == 1)
  {
    lcd.setCursor(0,lcdTopRow);
    lcd.print("                ");
    lcd.setCursor(0,lcdTopRow);
    lcd.print("Drop 1 Size");
    lcd.setCursor(cursorValue,1);
  }
}
/*
 
 
 */


void upkey()
{

  if (DropCount == 0)
  {
    lcd.setCursor(0,lcdTopRow);
    lcd.print ("                ");
    lcd.setCursor(0,lcdTopRow);
    lcd.print ("Drop Count");
    lcd.setCursor(0,lcdBottomRow);


  }
  if (cursorValue == 0)
  {




    DropCount = DropCount++;

    if (DropCount == 2  && cursorValue == 0)

    { 
      lcd.print (DropCount);
      lcd.print (" ");
      lcd.print (pulseWidth0);
      lcd.print (" ");
      lcd.print (pulseSep0);
      lcd.print (" ");
      lcd.print (pulseWidth1);
      lcd.print ("      ");
      lcd.setCursor(0,lcdBottomRow);

    }
    else if (DropCount == 3  && cursorValue == 0)

    { 
      lcd.print (DropCount);
      lcd.print (" ");
      lcd.print (pulseWidth0);
      lcd.print (" ");
      lcd.print (pulseSep0);
      lcd.print (" ");
      lcd.print (pulseWidth1);
      lcd.print (" ");
      lcd.print (pulseSep1);
      lcd.print (" ");
      lcd.print (pulseWidth2);
    }


    lcd.setCursor(0,lcdBottomRow);
    lcd.print(DropCount);
    lcd.setCursor(cursorValue,1);
  }

  if (DropCount >= 4)              
  {                                
    DropCount = 4;                 
    lcd.setCursor(0,lcdTopRow);    
    lcd.print("Max Drops = 3");    
    lcd.setCursor(0,lcdBottomRow);            
    lcd.print(DropCount);          
    lcd.setCursor(0,lcdBottomRow);            
  }                                


  else if (cursorValue == 2)  //increment tens of drop size 1
  {
    pulseWidth0 = pulseWidth0 + 10;

    if (pulseWidth0 >= 100)
    {
      pulseWidth0 = 99;
    }

    lcd.print(pulseWidth0);
    lcd.setCursor(cursorValue,1);
  }  
  else if (cursorValue == 3)  //increment units of drop size 1
  { 
    pulseWidth0 = pulseWidth0 +1;

    if (pulseWidth0 >= 100)
    {
      pulseWidth0 = 99;
    }

    if (pulseWidth0 <= 9)
    {
      lcd.setCursor(cursorValue -1,1);
      lcd.print(" ");
    }
    else if (pulseWidth0 >= 10)
    {
      lcd.setCursor(cursorValue -1,1); 
    }  
    lcd.print (pulseWidth0);
    lcd.setCursor(cursorValue,1);
  }  

  else if (cursorValue == 5)    //increment tens of drop seperation 1
  {
    pulseSep0 = pulseSep0 + 10;

    if (pulseSep0 >= 100)
    {
      pulseSep0 = 99;
    }
    lcd.print(pulseSep0);
    lcd.setCursor(cursorValue,1);
  }  
  else if (cursorValue == 6)  //increment units of drop size 1
  { 
    pulseSep0 = pulseSep0 +1;

    if (pulseSep0 >= 100)
    {
      pulseSep0 = 99;
    }

    if (pulseSep0 <= 9)
    {
      lcd.setCursor(cursorValue -1,1);
      lcd.print(" ");
    }
    else if (pulseSep0 >= 10)
    {
      lcd.setCursor(cursorValue -1,1); 
    }  
    lcd.print (pulseSep0);
    lcd.setCursor(cursorValue,1);
  } 

  else if (cursorValue == 8)  //increment tens of drop size 2
  {
    pulseWidth1 = pulseWidth1 + 10;

    if (pulseWidth1 >= 100)
    {
      pulseWidth1 = 99;
    }

    lcd.print(pulseWidth1);
    lcd.setCursor(cursorValue,1);
  }  
  else if (cursorValue == 9)  //increment units of drop size 2
  { 
    pulseWidth1 = pulseWidth1 +1;

    if (pulseWidth1 >= 100)
    {
      pulseWidth1 = 99;
    }
    if (pulseWidth1 <= 9)
    {
      lcd.setCursor(cursorValue -1,1);
      lcd.print(" ");
    }
    else if (pulseWidth1 >= 10)
    {
      lcd.setCursor(cursorValue -1,1);
    }
    lcd.print (pulseWidth1);
    lcd.setCursor(cursorValue,1);
  }  

  else if (cursorValue == 11)    //increment tens of drop seperation 2
  {
    pulseSep1 = pulseSep1 + 10;

    if (pulseSep1 >= 100)
    {
      pulseSep1 = 99;
    }
    lcd.print(pulseSep1);
    lcd.setCursor(cursorValue,1);
  }  
  else if (cursorValue == 12)      //increment units of drop seperation 2
  { 
    pulseSep1 = pulseSep1 +1;

    if (pulseSep1 >= 100)
    {
      pulseSep1 = 99;
    }
    if (pulseSep1 <= 9)
    {
      lcd.setCursor(cursorValue -1,1);
      lcd.print(" ");
    }
    else if (pulseSep1 >= 10)
    {
      lcd.setCursor(cursorValue -1,1);
    }
    lcd.print (pulseSep1);
    lcd.setCursor(cursorValue,1);
  }

  else if (cursorValue == 14)  //increment tens of drop size 3
  {
    pulseWidth2 = pulseWidth2 + 10;

    if (pulseWidth2 >= 100)
    {
      pulseWidth2 = 99;
    }

    lcd.print(pulseWidth2);
    lcd.setCursor(cursorValue,1);
  }  
  else if (cursorValue == 15)  //increment units of drop size 3
  { 
    pulseWidth2 = pulseWidth2 +1;

    if (pulseWidth2 >= 100)
    {
      pulseWidth2 = 99;
    }
    if (pulseWidth2 <= 9)
    {
      lcd.setCursor(cursorValue -1, 1);
      lcd.print(" ");
    }
    else if (pulseWidth2 >= 10)
    {
      lcd.setCursor(cursorValue -1,1);
    } 
    lcd.print (pulseWidth2);
    lcd.setCursor(cursorValue,1);
  }  
  return;
}
/*

 
 
 
 
 
 */
void downkey()
{
  if (DropCount == 4)
  {
    lcd.setCursor(0,lcdTopRow);
    lcd.print ("                ");
    lcd.setCursor(0,lcdTopRow);
    lcd.print ("Drop Count");
    lcd.setCursor(0,lcdBottomRow);

  }

  if (cursorValue == 0)
  {


    DropCount = DropCount--;

    if (DropCount <= 0)
    { 

      DropCount = 0;
      lcd.setCursor(0,lcdTopRow);
      lcd.print("Min Drops = 1");
      lcd.setCursor(0,lcdBottomRow);
      lcd.print(DropCount);
      lcd.setCursor(0,lcdBottomRow);
    }

    if (DropCount == 2  && cursorValue == 0)

    {

      lcd.print (DropCount);
      lcd.print (" ");
      lcd.print (pulseWidth0);
      lcd.print (" ");
      lcd.print (pulseSep0);
      lcd.print (" ");
      lcd.print (pulseWidth1);
      lcd.print ("      ");
      lcd.setCursor(0,lcdBottomRow);

    }
    if (DropCount == 1  && cursorValue == 0)

    { 
      lcd.print (DropCount);
      lcd.print (" ");
      lcd.print (pulseWidth0);
      lcd.print ("            ");
    }

    lcd.print(DropCount);
    lcd.setCursor(cursorValue,1);

  }

more of the code:

  else if (cursorValue == 2)  //decrement tens of drop size 1
  {
    pulseWidth0 = pulseWidth0 - 10;

    if (pulseWidth0 <= 9)
    {

      lcd.setCursor(cursorValue,1);  // put cursor in correct position to print just units
      // when the value is less than ten
      lcd.print(" ");
      cursorValue ++;
      lcd.setCursor(cursorValue ,1);
      lcd.print(pulseWidth0);
      lcd.setCursor(cursorValue,1);
    }

    if (pulseWidth0 == 0) //make sure pulswidth never goes to zero
    {
      pulseWidth0 = 1;
    }


    lcd.print(pulseWidth0);
    lcd.setCursor(cursorValue,1);
  }  
  else if (cursorValue == 3)  //decrement units of drop size 1
  { 
    pulseWidth0 = pulseWidth0 -1;

    if (pulseWidth0 == 0)     // make sure pulse width never goes to zerp
    {
      pulseWidth0 = 1;
    }

    if (pulseWidth0 <= 9)
    {
      lcd.setCursor(cursorValue -1,1);
      lcd.print(" ");
    }
    else if (pulseWidth0 >= 10)
    {
      lcd.setCursor(cursorValue -1,1);

    }

    lcd.print (pulseWidth0);
    lcd.setCursor(cursorValue,1);

  }


  else if (cursorValue == 5)    //decrement tens of drop seperation 1
  {
    pulseSep0 = pulseSep0 - 10;

    if (pulseSep0 <= 9)
    {

      lcd.setCursor(cursorValue,1);      // put cursor in correct position to print just units
      // when the value is lees than ten
      lcd.print(" ");
      cursorValue ++;
      lcd.setCursor(cursorValue ,1);
      lcd.print(pulseSep0);
      lcd.setCursor(cursorValue,1);
    }

    if (pulseSep0 == 0)                 //never let the seperation go to zero
    {
      pulseSep0 = 1;
    }


    lcd.print(pulseSep0);
    lcd.setCursor(cursorValue,1);
    //pulseSep0 = pulseSep0 - 10;
    // lcd.print(pulseSep0);
    lcd.setCursor(cursorValue,1);
  }  
  else if (cursorValue == 6)      //decrement units of drop seperation 1
  { 
    pulseSep0 = pulseSep0 -1;

    if (pulseSep0 == 0)     // make sure pulse width never goes to zerp
    {
      pulseSep0 = 1;
    }

    if (pulseSep0 <= 9)
    {
      lcd.setCursor(cursorValue -1,1);
      lcd.print(" ");
    }
    else if (pulseSep0 >= 10)
    {
      lcd.setCursor(cursorValue -1,1);

    }
    lcd.print (pulseSep0);
    lcd.setCursor(cursorValue,1);
  }
  else if (cursorValue == 8)  //decrement tens of drop size 1
  {
    pulseWidth1 = pulseWidth1 - 10;

    if (pulseWidth1 <= 9)
    {

      lcd.setCursor(cursorValue,1);  // put cursor in correct position to print just units
      // whne the value is lees than ten
      lcd.print(" ");
      cursorValue ++;
      lcd.setCursor(cursorValue ,1);
      lcd.print(pulseWidth1);
      lcd.setCursor(cursorValue,1);
    }

    if (pulseWidth1 == 0) //make sure pulswidth never goes to zero
    {
      pulseWidth1 = 1;
    }


    lcd.print(pulseWidth1);
    lcd.setCursor(cursorValue,1);
  }  

  else if (cursorValue == 9)  //decrement units of drop size 1
  { 
    pulseWidth1 = pulseWidth1 -1;

    if (pulseWidth1 == 0)     // make sure pulse width never goes to zerp
    {
      pulseWidth1 = 1;
    }

    if (pulseWidth1 <= 9)
    {
      lcd.setCursor(cursorValue -1,1);
      lcd.print(" ");
    }
    else if (pulseWidth1 >= 10)
    {
      lcd.setCursor(cursorValue -1,1);

    }

    lcd.print (pulseWidth1);
    lcd.setCursor(cursorValue,1);

  }


  else if (cursorValue == 11)    //decrement tens of drop seperation 2
  {
    pulseSep1 = pulseSep1 - 10;

    if (pulseSep1 <=9)

    {  
      lcd.setCursor(cursorValue,1);  // put cursor in correct position to print just units
      // when the value is less than ten
      lcd.print(" ");
      cursorValue ++;
      lcd.setCursor(cursorValue ,1);
      lcd.print(pulseSep1);
      lcd.setCursor(cursorValue,1);
    }

    if (pulseSep1 == 0) //make sure pulswidth never goes to zero
    {
      pulseSep1 = 1;
    }


    lcd.print(pulseSep1);
    lcd.setCursor(cursorValue,1);
  } 


  else if (cursorValue == 12)      //decrement units of drop seperation 2
  { 
    pulseSep1 = pulseSep1 -1;
    if (pulseSep1 == 0)     // make sure pulse width never goes to zerp
    {
      pulseSep1 = 1;
    }

    if (pulseSep1 <= 9)
    {
      lcd.setCursor(cursorValue -1,1);
      lcd.print(" ");
    }
    else if (pulseSep1 >= 10)
    {
      lcd.setCursor(cursorValue -1,1);

    }

    lcd.print (pulseSep1);
    lcd.setCursor(cursorValue,1);
  }

  else if (cursorValue == 14)  //decrement tens of drop size 3
  {
    pulseWidth2 = pulseWidth2 - 10;

    if (pulseWidth2 <= 9)
    {

      lcd.setCursor(cursorValue,1);  // put cursor in correct position to print just units
      // when the value is less than ten
      lcd.print(" ");
      cursorValue ++;
      lcd.setCursor(cursorValue ,1);
      lcd.print(pulseWidth2);
      lcd.setCursor(cursorValue,1);
    }

    if (pulseWidth2 == 0) //make sure pulswidth never goes to zero
    {
      pulseWidth0 = 1;
    }


    lcd.print(pulseWidth2);
    lcd.setCursor(cursorValue,1);
  }  
  else if (cursorValue == 15)  //decrement units of drop size 3
  { 

    pulseWidth2 = pulseWidth2 -1;

    if (pulseWidth2 == 0)     // make sure pulse width never goes to zerp
    {
      pulseWidth2 = 1;
    }

    if (pulseWidth2 <= 9)
    {
      lcd.setCursor(cursorValue -1,1);
      lcd.print(" ");
    }
    else if (pulseWidth2 >= 10)
    {
      lcd.setCursor(cursorValue -1,1);

    }


    lcd.print (pulseWidth2);
    lcd.setCursor(cursorValue,1);
  }  

  return;

}

and finally the last chunk of code:

void outloop()

{ 

  digitalWrite(backLightControl,backLightOFF);      //Backlight OFF

    delay(1500);

  digitalWrite (timerTrigger,triggerON);   //Trigger the timer box



  if (DropCount == 1) 

    //  Output 1 drop  

  { 
    digitalWrite(ledpin,ledpinON);        // heartbeat
    digitalWrite(valveControl,VLVON);   //Valve ON
    digitalWrite(dropsAway,dropsAwayON);     //indicator LED on

    delay (pulseWidth0);              //set drop 1 size

    digitalWrite(valveControl,VLVOFF);      //Valve OFF
    digitalWrite(dropsAway,dropsAwayOFF);    //Indicator OFF
    digitalWrite(ledpin,VLVON);
    digitalWrite(timerTrigger,triggerOFF);   //reset the timer trigger

    EEPROM.write(0,DropCount);         // store our variables for next startup
    EEPROM.write(1,pulseWidth0);

    delay(2000);                     //  Make sure Camera is done 
    digitalWrite(backLightControl,backLightON);   //Backlight ON
  }


  else if (DropCount == 2)

    // output 2 drops

  {
    digitalWrite(ledpin,ledpinON);
    digitalWrite(valveControl,VLVON);   //Valve ON
    digitalWrite(dropsAway,dropsAwayON);     //indicator LED on

    delay (pulseWidth0);              //set drop 1 size

    digitalWrite(valveControl,VLVOFF);  //Valve OFF
    digitalWrite(timerTrigger,triggerOFF);
    digitalWrite(ledpin,ledpinOFF);
    digitalWrite(dropsAway,dropsAwayOFF);    //Indicator OFF

      delay(pulseSep0);                  //this is the delay that separates the drop 1 & 2

    digitalWrite(ledpin,ledpinON);
    digitalWrite(valveControl,VLVON);   //Valve ON
    digitalWrite(dropsAway,dropsAwayON);     //indicator LED on

    delay (pulseWidth1);              //set drop 2 size

    digitalWrite(valveControl,VLVOFF);  //Valve OFF
    digitalWrite(ledpin,ledpinOFF);
    digitalWrite(dropsAway,dropsAwayOFF);    //Indicator OFF

    EEPROM.write(0,DropCount);        // store our variables for next startup
    EEPROM.write(1,pulseWidth0);
    EEPROM.write(2,pulseSep0);
    EEPROM.write(3,pulseWidth1);

    delay(2000);                      //Make sure Camera is done 
    digitalWrite(backLightControl,backLightON);     //Backlight ON
  }



  else if (DropCount == 3)    

    //  Output 3 drops  

  {
    digitalWrite(ledpin,ledpinON);
    digitalWrite(valveControl,VLVON);   //Valve ON
    digitalWrite(dropsAway,dropsAwayON);     //indicator LED on

    delay (pulseWidth0);              //set drop size

    digitalWrite(valveControl,VLVOFF);  //Valve OFF
    digitalWrite(ledpin,ledpinOFF);
    digitalWrite(dropsAway,dropsAwayOFF);    //Indicator OFF
    digitalWrite(timerTrigger,triggerOFF);   // flash timer reset

    delay(pulseSep0);                  //set drop separation

    digitalWrite(ledpin,ledpinON);
    digitalWrite(valveControl,VLVON);    //Valve ON
    digitalWrite(dropsAway,dropsAwayON);     //indicator LED on

    delay (pulseWidth1);               //set drop 2 size

    digitalWrite(valveControl,VLVOFF);   //Valve OFF
    digitalWrite(dropsAway,dropsAwayOFF);    //Indicator OFF
    digitalWrite(ledpin,ledpinOFF);

    delay(pulseSep1);                  //set delay between drop 2 and 3

    digitalWrite(ledpin,ledpinON);
    digitalWrite(valveControl,VLVON);   //Valve ON
    digitalWrite(dropsAway,dropsAwayON);     //indicator LED on

    delay (pulseWidth2);

    digitalWrite(valveControl,VLVOFF);  //Valve OFF
    digitalWrite(dropsAway,dropsAwayOFF);    //Indicator OFF
    digitalWrite(ledpin,ledpinOFF);

    EEPROM.write(0,DropCount);        // store our variables for next startup
    EEPROM.write(1,pulseWidth0);
    EEPROM.write(2,pulseSep0);
    EEPROM.write(3,pulseWidth1);
    EEPROM.write(4,pulseSep1);
    EEPROM.write(5,pulseWidth2);
    
    delay(2000);                      //  Make sure Camera is done 
    
    digitalWrite(backLightControl,backLightON);     //Backlight ON

  }             
}

Is there a better way of posting long code. The way I did it is a kluge at best. Hopefully a mod can consolidate the code into one window by overriding the 9500 limit.

RWW

RogerW: Is there a better way of posting long code....

Instead of trying to post the code in a window, here's a possibility:

1. Compress the file(s) with zip (or with GNU gzip or bzip2).

2. When are creating your post, put the description and/or other narrative in the edit window. Then click the little Additional Options triangle below the left bottom of the edit window. Use the Browse button to the right of the Attach: line. to find the zipped file and attach it.

People who are interested can download it, whereas people who are just browsing won't be bothered with it.

Regards,

Dave

Thanks for the tip Dave. I tried to compress the file but was not successful. My wife's Vista computer could not find Zip and would not run either of the other two programs you suggested.

RWW

Hi Roger,

i'm new in arduino and going to make something like what u have made. but i going to start with a short program to make me understand more bout this programming. the project i have made now as below.

i'm thinking to use the LCD shield like yours and wanted to use it just to show the flashFireDelay and change the value, can u guide me on how i should edit the script?

many thanks in advance...

Sensor = 2; //sensor to detect waterdrop int SensorStat = 0; int led = 13; //output signal to trigger flash int flashFireDelay = 1000; //delay after sensor detect water drop and trigger the flash

void setup() {

pinMode(Sensor, INPUT); pinMode(led, OUTPUT); Serial.begin(9600);

}

void loop() { SensorStat = digitalRead(Sensor); if (SensorStat == HIGH){ //when sensor detect water drop delay(flashFireDelay); //delay time before flash fire digitalWrite(led, HIGH); //flash fired after the delay }

else {digitalWrite(led, LOW); }

Serial.println(SensorStat, DEC); }

Cool project. Please post the results -- aka the great photos you are going to take!

You could also consider making one of time fountains (though they detect the actual drop instead of triggering the drop).

http://www.youtube.com/watch?v=rvY7NGncCgU

Wicked cool!!!!!!!!!! Splitting water drops and moving them up and down. What strobe frequency are you using? I am guessing around 10Hz. I feel a bit strange when staring at a strobe light but for this end result I'm willing to give it a try sometime. Synchronized drops. What happens when you don't have the synchronization? The water drops move slowly up or down, right?

RogerW: Is there a better way of posting long code...

You can post the code at www.github.com. You've created an awesome project. I was looking for something like this for quite some time now. :)

Hi Roger,

I have just built an Arduino trigger system to photograph high speed objects such as water drops. Luckily I found your posting and have built a water drop controller using your code. The system is essentially the same, although I have yet to complete the switching circuit. I have however hit a snag. I am very new to programming and cannot quite figure out why my lcd display is defaulting to 255 for the drop sizes, i.e. Drop count = 2 255 255 255. I cannot seem to get it to default to 99. As far as I can tell the only difference in the setup is that I am using the sainsmart lcd shield which is virtually identical. Other than that it appears to work fine.

I'd be grateful for any thoughts.

Hi !
I’ve built the same circuit I encountred the same issue : The probleme is with intial values on e2p.
Add this code in setup function it should fix it :wink:

 //load our variables from EEPROM
  DropCount = EEPROM.read(0);

  if(DropCount < 4)
  {
	  pulseWidth0 = EEPROM.read(1);
	  pulseSep0 = EEPROM.read(2);
	  pulseWidth1 = EEPROM.read(3);
	  pulseSep1 = EEPROM.read(4);
	  pulseWidth2 = EEPROM.read(5);
  }
  else // reset factory
  {
	DropCount = 1;
    EEPROM.write(0,DropCount);        // store our variables for next startup
    EEPROM.write(1,pulseWidth0);
    EEPROM.write(2,pulseSep0);
    EEPROM.write(3,pulseWidth1);
    EEPROM.write(4,pulseSep1);
    EEPROM.write(5,pulseWidth2);
  }

A big thank for RogerW btw :slight_smile:

there is a chance to add here flash timer, when release the flash ? and setting delay for it ?

i am newbie in code so for me is impossible, someone can help ?

id love to do this , but I have no idea what parts I need . never had a arduino before but if someone could guide me. that would be great. wonder if its best I start a new topic im not clued up on forums either :)

can you give us a circuit for the bottem board in your design i cant get it clear what ic it is and how it is conected

Hello Roger and thanks for this project wich Ive build for our photographyclub. There is a little problem when I start up, the dropcounter only stay in the 1 drop state. I can’t get it to 2,3 or 4 drops with the upkey. Itried a lot, putting off all the code for the EE-prom, but no change. The up-key seems to work ok, when I use it to increase the droptime it wiil go up. Hope someone can help me, because I’m a beginner in C-programming.

Many thanks in advandge

Jan

jandeilander: Hello Roger and thanks for this project wich Ive build for our photographyclub. There is a little problem when I start up, the dropcounter only stay in the 1 drop state. I can't get it to 2,3 or 4 drops with the upkey. Itried a lot, putting off all the code for the EE-prom, but no change. The up-key seems to work ok, when I use it to increase the droptime it wiil go up. Hope someone can help me, because I'm a beginner in C-programming.

Many thanks in advandge

Jan

The fix for this is to download an older version, the newer version seems to compile it differently.

can be found here

http://arduino.googlecode.com/files/arduino-1.0.5-r2-windows.exe

hello whosthedybbuk, im new and im trying to make this project, but the display has several problems, please could u send me via email the full sketch modified from you? it will be great for me thanks antonio

email falduto.antonio@live.it

What are you running out of? code space or RAM?

You're using a lot of

lcd.print(....)

this uses loads of RAM.

Try

lcd.print(F(........))

  • this puts the strings in flash and saves loads of RAM

regards

Allan