user57412: i am working on a project for my school tech class. Our goal is to make a vehicle that will travel along a cable and drop an egg to a target while going down the cable. i am using an arduino to to open a trap door with a servo after a certain amount of time that is set by two push buttons, and a third push button will control when the timer starts.
Here is my circuit

Here is the code:
#include <Servo.h>
#include <LiquidCrystal.h>

int b = 0;
int up = 0;
int down = 0;
int val = 100;


LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

Servo myservo; 

int pos = 0;    

void setup() 
{
  pinMode(b, INPUT);
  pinMode(up, INPUT);
  pinMode(down, INPUT);
  lcd.begin(16, 2);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() 
{
  digitalRead(down);
  digitalRead(up);
  digitalRead(b);
  lcd.setCursor(0, 0);
  lcd.print("milli seconds:");

  while (b == HIGH)
  {
    digitalRead(down);
    digitalRead(up);
    digitalRead(b);
    lcd.setCursor(0, 1);
    lcd.print(val);
    myservo.write(0);
    if (up == HIGH, down == LOW)
    {
      val + 1;
    }  
    if (down == HIGH, up == LOW )
    {
      val - 1;
    }

    delay(val);
    myservo.write(100);
    delay(1000);
  }
}


user20533: in setup you are calling
pinMode(b, INPUT);
pinMode(up, INPUT);
pinMode(down, INPUT);

but b, up and down all equal 0 so this is what you are doing is :
pinMode(0, INPUT)
pinMode(0, INPUT)
pinMode(0, INPUT)

This doesn't do what you want at all, these need to be assigned to pins. All you are doing is repeatedly setting arduino digital pin 0 to INPUT 3 times.
secondly
while(b == HIGH)

will never fire since b is 0 and is never set to anything else. so it will never == HIGH
Finally,
digitalRead(down);

doesn't do anything useful; what it does is read from pin down which is set to 0, and then drops the return value on the floor
also, this,
if (up == HIGH, down == LOW)

is just very wrong, sholud be
if (up == HIGH && down == LOW)

anyway based on you scematic, fixing this code:
#include <Servo.h>
#include <LiquidCrystal.h>

const int B = 7;
const int UP = 8;
const int DOWN = 9;
int val = 100;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

Servo myservo; 

int pos = 0;    

void setup() 
{
  pinMode(B, INPUT);
  pinMode(UP, INPUT);
  pinMode(DOWN, INPUT);
  lcd.begin(16, 2);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  lcd.setCursor(0, 0);
  lcd.print("milli seconds:");
}

void loop() 
{
  // todo: debounce the switches
  int up = digitalRead(UP);
  int down = digitalRead(DOWN);
  int b = digitalRead(B);  

  if (up == HIGH && down == LOW)
  {
     val += 1  // todo: handle overflow
  }

  if (down == HIGH && up == LOW )
  {
     val -= 1
  }

  lcd.setCursor(0, 1);
  lcd.print(val);

  if(b == HIGH)
  {
    myservo.write(0);
    delay(val);
    myservo.write(100);
    delay(val);      
  }

}

this will do what the origonal code was trying to do, more or less, but the 
proper way to do this would be (in psuedo-code):
// Setup pins etc.
// Setup(): pinMode(...) ... etc.
// Loop():
//   debounce buttons
//   handle up/down
//   record milliseconds when button is pressed
//   see how much time has passed
//   trigger servo when timer has passed


57412: <p>i am working on a project for my school tech class. Our goal is to make a vehicle that will travel along a cable and drop an egg to a target while going down the cable. i am using an arduino to to open a trap door with a servo after a certain amount of time that is set by two push buttons, and a third push button will control when the timer starts.
Here is my circuit
<a href="https://i.stack.imgur.com/5TTl1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5TTl1.png" alt="enter image description here"></a></p>

<p>Here is the code:</p>

<pre><code>#include &lt;Servo.h&gt;
#include &lt;LiquidCrystal.h&gt;

int b = 0;
int up = 0;
int down = 0;
int val = 100;


LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

Servo myservo; 

int pos = 0;    

void setup() 
{
  pinMode(b, INPUT);
  pinMode(up, INPUT);
  pinMode(down, INPUT);
  lcd.begin(16, 2);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() 
{
  digitalRead(down);
  digitalRead(up);
  digitalRead(b);
  lcd.setCursor(0, 0);
  lcd.print("milli seconds:");

  while (b == HIGH)
  {
    digitalRead(down);
    digitalRead(up);
    digitalRead(b);
    lcd.setCursor(0, 1);
    lcd.print(val);
    myservo.write(0);
    if (up == HIGH, down == LOW)
    {
      val + 1;
    }  
    if (down == HIGH, up == LOW )
    {
      val - 1;
    }

    delay(val);
    myservo.write(100);
    delay(1000);
  }
}
</code></pre>
 20533: <p>in setup you are calling</p>

<pre><code>pinMode(b, INPUT);
pinMode(up, INPUT);
pinMode(down, INPUT);
</code></pre>

<p>but b, up and down all equal 0 so this is what you are doing is :</p>

<pre><code>pinMode(0, INPUT)
pinMode(0, INPUT)
pinMode(0, INPUT)
</code></pre>

<p>This doesn't do what you want at all, these need to be assigned to pins. All you are doing is repeatedly setting arduino digital pin 0 to INPUT 3 times.</p>

<p>secondly</p>

<pre><code>while(b == HIGH)
</code></pre>

<p>will never fire since b is 0 and is never set to anything else. so it will never == HIGH</p>

<p>Finally,</p>

<pre><code>digitalRead(down);
</code></pre>

<p>doesn't do anything useful; what it does is read from pin down which is set to 0, and then drops the return value on the floor</p>

<p>also, this,</p>

<pre><code>if (up == HIGH, down == LOW)
</code></pre>

<p>is just very wrong, sholud be</p>

<pre><code>if (up == HIGH &amp;&amp; down == LOW)
</code></pre>

<p>anyway based on you scematic, fixing this code:</p>

<pre><code>#include &lt;Servo.h&gt;
#include &lt;LiquidCrystal.h&gt;

const int B = 7;
const int UP = 8;
const int DOWN = 9;
int val = 100;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

Servo myservo; 

int pos = 0;    

void setup() 
{
  pinMode(B, INPUT);
  pinMode(UP, INPUT);
  pinMode(DOWN, INPUT);
  lcd.begin(16, 2);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  lcd.setCursor(0, 0);
  lcd.print("milli seconds:");
}

void loop() 
{
  // todo: debounce the switches
  int up = digitalRead(UP);
  int down = digitalRead(DOWN);
  int b = digitalRead(B);  

  if (up == HIGH &amp;&amp; down == LOW)
  {
     val += 1  // todo: handle overflow
  }

  if (down == HIGH &amp;&amp; up == LOW )
  {
     val -= 1
  }

  lcd.setCursor(0, 1);
  lcd.print(val);

  if(b == HIGH)
  {
    myservo.write(0);
    delay(val);
    myservo.write(100);
    delay(val);      
  }

}
</code></pre>

<p>this will do what the origonal code was trying to do, more or less, but the 
proper way to do this would be (in psuedo-code):</p>

<pre><code>// Setup pins etc.
// Setup(): pinMode(...) ... etc.
// Loop():
//   debounce buttons
//   handle up/down
//   record milliseconds when button is pressed
//   see how much time has passed
//   trigger servo when timer has passed
</code></pre>
