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);
}
}