ArduinoPalmer

So im pretty new with this stuff and Im having trouble merging two ideas into one program.I basically want the functions of example 05 but I want to use the touch sensor (project 13) as my pushbutton switch. below are the two separate arduino codes.

------------------------------------------------// Example 05: Turn on LED when the button is pressed // and keep it on after it is released// including simple de-bouncing.// If the button is held, brightness changes. //// Copy and paste this example into an empty Arduino sketch

#define LED 9 // the pin for the LED #define BUTTON 7 // input pin of the pushbutton

int val = 0; // stores the state of the input pin

int old_val = 0; // stores the previous value of "val" int state = 0; // 0 = LED off while 1 = LED on

void setup() { // open a serial connection Serial.begin(9600); // set the LED pin as an output pinMode(ledPin, OUTPUT);}

void loop() { // store the value reported by the sensor in a variable long sensorValue = capSensor.capacitiveSensor(30);

// print out the sensor value Serial.println(sensorValue);

// if the value is greater than the threshold if(sensorValue > threshold) { // turn the LED on digitalWrite(ledPin, HIGH); } // if it's lower than the threshold else { // turn the LED off digitalWrite(ledPin, LOW); }