Sequence of events

Hi Guys
I am new to the Forum but am after a little bit of advice on a sketch i am trying to run.
I am using LED's which will be replaced by other components eventually, once the sketch is working.

I have a project which involves 2 LED's one to the Left and one to the Right.
Currently I am controlling the LED's via Potentiometers one for the left LED and one for the Right LED.
The Left LED must light up when the Potentiometer is turned from a high input to 0, when the input is at 0 the Left LED and the Right LED must light up for 2 seconds then turn off. They must remain off until the Potentiometer is turned up then again back to 0.
The same must happen when the Right Potentiometer is turned.

This is a simplified version of events but a good starting point.

Any advice would be greatly appreciated, and thanks in advance.

Ok. so what is happening and what is not happening? Where is the code you are using?

Paul

Thank you for your swift replies, I had to skeddadle though last night.
OK I have written the code to allow the the LED to be turned on which seems to work.
The next objective is for the LED to to turn off after 2 seconds and stay off even if the Pot reads from 0-4.
The sequence would be started againonce the Pot goes above 4.
I hope this makes sense.
See the curent Code below

/*
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the serial monitor.
Graphical representation is available using serial plotter (Tools > Serial Plotter menu)

*/
int ledPinl = 10; // The LED is connected to digital pin 11 actually multimeter
int ledPinr= 11; // The LED is connected to digital pin 12 actually multimeter
const int PIEZO_PINR = A2; // Piezo output
const int PIEZO_PINL= A3; // Piezo output
const int FLEX_PIN = A0; // Pin connected to voltage divider output

int buttonState = 0;
int lastButtonState = 1;

// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// initialize digital pin 10 and 11 as an output.
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
analogWrite (ledPinl, 127);
analogWrite (ledPinr, 127);

}

// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue00 = analogRead(A3);
Serial.print(", Sensor Value 00: ");
Serial.println(sensorValue00);
delay(100); // delay in between reads for stability
// read the input on analog pin 1:
int sensorValue01 = analogRead(A4);
// if the analog value is high enough, turn on the LED:
// print out the value you read:
Serial.print(", Sensor Value 01: ");
Serial.println(sensorValue01);
delay(10); // delay in between reads for stability

// read the pushbutton input pin:
buttonState = analogRead(A3); // compare the buttonState to its previous state

if (buttonState < lastButtonState) analogWrite(ledPinr, 255);// if the current state is below 01 turns on Right LED

}

Delta_G:
NEXT STEP: Write a program that can turn on an LED if the pots value is 0 now but wasn't 0 the last time it was read. This will look a lot like the State Change example except it will track the pot reading instead of a pin state.

Hi Delta_G I have managed write the program similar to your suggestion which works now I am working on a delay, hopefully this will get things working well for the next part of the programming, Oh and many thanks for you suggestion.