Mikrobasic Pro Code
program georgialarm
dim oldstate as bit
sub procedure alarm
Sound_Play(9000, 1500)
delay_ms(2000)
Sound_Play(5777, 1500)
if button (PORTB,0,10,0 )then return 'BUTTON GIA APENERGOPOIISI
end if
while 1
if button (PORTB,0,10,0 )then BREAK
end if
Sound_Play(5777, 750)
Sound_Play(377, 150)
'porta=0x00
portb.4=1 'RELLE GIA SYNAGERMO
DELAY_MS(2000)
WEND
end sub
SUB PROCEDURE OPLISMOS
'PORTA.2=1
Sound_Play(3456, 250)
delay_ms(2000)
Sound_Play(3456, 250)
delay_ms(1500)
Sound_Play(3456, 250)
delay_ms(1000)
Sound_Play(3456, 250)
delay_ms(800)
Sound_Play(3456, 250)
delay_ms(600)
Sound_Play(3456, 250)
delay_ms(400)
Sound_Play(3456, 250)
delay_ms(200)
Sound_Play(3456, 250)
delay_ms(100)
Sound_Play(3456, 250)
delay_ms(50)
Sound_Play(3456, 250)
delay_ms(50)
Sound_Play(3456, 250)
delay_ms(50)
Sound_Play(3456, 250)
delay_ms(50)
Sound_Play(3456, 250)
delay_ms(3000)
Sound_Play(5777, 2500)
PORTA.3=1 'LED OPLISMOU
END SUB
main:
cmcon=0 'disable comparators
vrcon=0
porta=0
trisa=0
trisb=0x0F
Sound_Init(PORTA, 2)
Sound_Play(8500, 4000)
while 1
PORTB.4=0
PORTA.0=0
PORTA.3=1
''edw anapoda to diakoptaki to 1 ginetai 0 k to 0 ginetai 1
if (Button(PORTB, 1, 1, 0) <> 0) then ' Detect logical one logw tou magnitikou diakopti pou einai anoixtos otan einai enwmenos'
oldstate = 1 ' Update flag
end if
if (oldstate and Button(PORTB, 1, 1, 1)) then 'BUTTON FOR ALARM ON ' Detect one-to-zero transition
alarm ' Invert PORTC
oldstate = 0 ' Update flag
end if'
'
if (Button(PORTB, 2, 1, 1) <> 0) then ' Detect logical one
oldstate = 1 ' Update flag
end if
if (oldstate and Button(PORTB, 2, 1, 0)) then 'BUTTON GIA OPLISMO ' Detect one-to-zero transition
OPLISMOS ' Invert PORTC
oldstate = 0 ' Update flag
end if
wend
end.