Capacitive Touch Lamp - Mode Problems

You are only checking the value of mode and setting the lamp output when the lamp is touched. When the value of mode rolls over and is set back to 0 no action is taken immediately unless you have the analog.write in place.

Look at the BlinkWithoutDelay example in the IDE to see how to avoid the use of delay(). The basic idea is to note a start time, do stuff, check whether the 'delay' period has elapsed and if not, do stuff until it is. The timing is done using the millis() function which does not block the execution of other code.