PDA

View Full Version : intervall timer siren



oeloeg
- 7th August 2011, 15:15
I need intervall siren... with recordable time off and on...(at startup push button for time on, release wait and push again to record time off)
I 've done it this way for now but I want also to change the sound
Now I have to change the times each time...
Is it more easy with timer? don't know how...



program BIEP

dim count as byte
dim counter as byte
dim time1 as byte
dim time2 as byte

main: 'start main program
TRISD = %01100000
Sound_Init(PORTC, 3)

record:
if (Button(PORTD,1,1,1)) then 'record time
time1 = 0
time2 = 0

while (Button(PORTD,1,1,1)) 'record on time
time1 = time1 + 1 'time1 + 1 (250ms)
delay_ms(250) '+1 = 250ms
wend 'end loop

while (Button(PORTD,1,0,0)) 'record off time
time2 = time2 + 1 'time2 + 1 (250ms)
delay_ms(250) '+1 = 250ms
wend 'end loop

else
goto loop
end if

loop: 'begin loop program

if (Button(PORTD,2,0,0)) then
for count = (time1/2) to 0 step -1
Sound_Play(730, 250) 'siren
Sound_Play(1152, 250)
next count
else


for count = (time1*3) to 0 step -1
Sound_Play(730, 25) 'siren 2
Sound_Play(935, 25)
Sound_Play(1152, 25)
next count

end if 'einde knop D.2 detectie

for counter = time2 to 1 step -1
delay_ms(250) 'pauze = time2 * 250ms
next counter

goto loop
end.

mackrackit
- 7th August 2011, 16:46
The folks at this forum will be able to help you, I think.
http://www.protonbasic.co.uk/