# Expression 2 - Help - Read !

Hello…

im trying this for 2 days now with out any succes.

im trying to build a door wich opens by a timer made in Expression2

this is an axample:

if (target1>=1) {timer(“Timer1”,5000)}
if (clk(“Timer1”)) {Door1 = 90} else {Door1 = 0}

evrytime the timer1 is done and it should make the door go to 90 it does it for like 0,01 sec…

how !? am i supposed to let him stay on 90 for like 5 sec ?

Im not a realy experienced e2’r but i sure want to learn.
and i know that this might be easy for some but for me its not

so please someone explain to me why that what i wrote is FAIL ?

You require a second timer.

``````

if (target1>=1) {timer("Timer1",5000)}
if (clk("Timer1")) {Door1 = 90,timer("Timer2",5000)}
if (clk("Timer2")) {Door1 = 0}

``````

Or if I wish to do something crazy…

``````

@inputs Open
@outputs Door
if (~Open) {timer("Open",5000)}
if (clk("Open")) {
Door = !Door*90
if (Door) {timer("Open",5000}
}

``````

i will try it at once !

It Works now :O.

only a new Problem has accured…

the timer keeps starting if target = 1

so if i stand in there for 10 sec the e2 has playd the timer 4+ times…
how to run it only once and when its total done with opening and closing door than he must reset…

Alternatively, you could simply use a timer and comparisons.

``````

@persist DM
timer("Timer",5000)
if(target1>=1 & clk){DM++
if(DM==1){Door1=90}
if(DM==2){Door1=0}
if(DM>2){DM=1}
}

``````

The example above… isnt the whole thing

its a very long e2 with allot ! of timers XD…

the only down point is. it keeps repeating it self evry 5 sec… so if i got a sound… it will repeat it self evry 5 sec… until target = 1

i want it to be only once if target = 1 the whole e2 will be playd once…
if target = 0 nothnig happends
when target = 1 again it will play the whole e2 again…

I can’t read your writing. You’re like Charlie Gordon when he first discovered punctuation.

What the fuck are you guys doing?

The first code won’t simply won’t work and the second one will never stop running…

Also did you ever heard of elseifs?

``````

@inputs input
@outputs output
#if code gets triggered more often, check if the execution was triggered by any input
if (input>=1 & ~input) {
timer("open",5000)
timer("close",10000)
}elseif(clk("open")){
output = 90
}elseif(clk("close")){
output = 0
}

``````

[editline]1st February 2011[/editline]

I hate E2.

[editline]1st February 2011[/editline]

Oh wait the second code wouldn’t work either