Catapult w/ 2 servos controlled by a sensor (TMP36 or photoresistor)

I am having trouble incorporating readings from a sensor to control my dual servo catapult I’m looking for advice first and if I can’t get it then the Solution. Below is my code which fires the catapult in a loop, with locking, arming and firing. I have had trouble with incorporating the servos into the sketchbook “love-o-meter” code which uses the TMP36.
I want a change in temperature to trigger the catapult or even easier, trigger the code I have written and then stop the code after the temp drops again, the threshold can be as small as +2 degrees C .

#include <Servo.h>

Servo servoLeft; // Define left servo SMALL
Servo servoRight; // Define right servo LARGE

void setup() {
servoLeft.attach(10); // Set left servo to digital pin 10
servoRight.attach(9); // Set right servo to digital pin 9

}

void loop() {
Lock();
delay(2000); // Wait 2 seconds
Arm();
delay(2000);
Fire();
delay(2000);
}

void Trigger Lock() {
delay(1000);
servoRight.write(90);
servoLeft.write(90);

}

void Arm() {
servoRight.write(0);
delay(3000);
servoLeft.write(0);

}

void Fire() {
servoRight.write(90);
delay(1000);
servoLeft.write(90);

}

Thanks in advance!!!

LATEST CODE HERE WILL COMPILE FINALLY. I honesly just want to press a push button and have it run my code.

#include <Servo.h>

const int buttonPin = 2; //button used to move servo to lock position, attached to digital input 2
int buttonState = 0; //initial state of button
int threshold=70; //threshold value of sensor at which the catapult launches (change this to fit your needs)
Servo servoLeft; // Define left servo SMALL
Servo servoRight; // Define right servo LARGE

void setup() {
servoLeft.attach(10); // Set left servo to digital pin 10
servoRight.attach(9); // Set right servo to digital pin 9
Serial.begin(9600); //display serial input (reads pressure sensor value - adjust threshold accordingly)
pinMode(buttonPin, INPUT); //make the button pin an input pin

}

void loop() {
buttonState = digitalRead(buttonPin); //read value of button

if(buttonState == HIGH) { //if button pressed…
void Lock();
servoRight.write(90);
servoLeft.write(90);

void Arm();
servoRight.write(0);
delay(3000);
servoLeft.write(0);

void Fire();
servoRight.write(90);
delay(1000);
servoLeft.write(90);

}

}

LATEST CODE HERE WILL COMPILE FINALLY.

Really?
The code is a nonsense.
First read how to use this forum sticky post and post your code correctly.

Then look up how to define and use of functions.

As you at this stage know nothing, always start from an example, you find them in the file menu under examples. Each library should have at least one example, the servo library is no exception.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks… Tom… :slight_smile: