bigal_scorpio
Active Member
Hi to all,
I am not yet very good with Microprocessors and am trying to learn MikroBasic. But being a late starter I am finding it difficult to get my head round.
I have written a program to give 3 pulses when the ignition of the car is turned on, then it must wait until the ignition is turned off and again send 3 pulses.
I have managed to get a working program but a friend looked at it and said it could be done much easier and smaller, but seemed unwilling or unable to explain how, so could anyone who uses basic have a quick look and advise me what I SHOULD be doing.
Thanks........Al
I am not yet very good with Microprocessors and am trying to learn MikroBasic. But being a late starter I am finding it difficult to get my head round.
I have written a program to give 3 pulses when the ignition of the car is turned on, then it must wait until the ignition is turned off and again send 3 pulses.
I have managed to get a working program but a friend looked at it and said it could be done much easier and smaller, but seemed unwilling or unable to explain how, so could anyone who uses basic have a quick look and advise me what I SHOULD be doing.
Thanks........Al
Code:
'Program to send 3 pulses on ignition being turned on
'then waiting for ignition off to send another set of 3 pulses
' using 12F629 with MCLR off, BODEN off, PWRTE on, WDT off, INT OSC No Clockout
'Power to GPIO.0 from ignition through voltage divider
program tripleflash3
dim t as byte
main:
TRISIO = %00000001
CMCON = 7
if Button(GPIO,0,1,0) then
goto main
end if
if Button(GPIO,0,1,1) then
For t = 1 to 3
GPIO.1 = 1
Delay_ms(100)
GPIO.1 = 0
Delay_ms(100)
next t
end if
waiter:
if Button(GPIO,0,1,1) then
goto waiter
end if
For t = 1 to 3
GPIO.1 = 1
Delay_ms(100)
GPIO.1 = 0
Delay_ms(100)
next t
goto main
end.