I have an audio signal that turns ledPin12 on and off via analogRead. I want to be able to write ledPin2 high if ledPin12 has been low for 2 seconds, but once pin 12 goes high, I want pin 2 to go low IMMEDIATELY and reset the timer.
Then what is all the rest of that stuff for? Deal with ONE problem.
Since pin 12 is an OUTPUT, you control when it goes LOW and when it goes HIGH. So, setting pin 2 LOW immediately should not be a problem. Noting when pin 12 goes LOW is easy. Noting how long the pin has been LOW is trivial.
ledPin11 = HIGH;
Why are you changing the value in this variable, a pin number, to 1?
This might as well be
Maybe you need some more curly braces.
val = analogRead(0); //selects values 2-27
val = map(val, 100, 1000, 2, 27);
This does. The other statement does not.
int pulseGenState = digitalRead(ledPin12);
Having global and local variables of the same name is just plain stupid. I quit reading at this point.