Sonsivri

Electronics => Pic Basic Languages => Topic started by: Korvo on November 11, 2011, 11:18:41 11:18



Title: Help with picaxe08M
Post by: Korvo on November 11, 2011, 11:18:41 11:18
Hi, i'm new to programming Pic, Avr and picaxe, so i begin with picaxe to learn more.
After some experiences with picaxe08m I intend to make the folow program:
2 push buttons and 2 leds
press push button 1 -> on led1 3 seconds -> if press push button 1 during the 3 seconds -> led 1 off
                                                                     -> if no press button -> off led1 after the 3 seconds
the same for push button 2 and led 2

one condition: Never on led 1 and led 2 at the same time

I used the setinterrupt function, but not work properly, maybe i don't understand this function properly.
My code is:

let dirs = %00000110
main:
    If pin4 = 1 then  led1
    If pin3 = 1 then led2
  goto main

led1:
     setint %10010000,%10010000
     high 2
     pause 3000
     low 2
   goto main

interrupt:
     if pin4 = 1  or pin3 = 1 then
     low 2
     low 1
   end if
setint %10000000,%10000000
  goto main

led2:
    setint %10001000,%10001000
    high 1
    pause 3000
    low 1
   goto main   

Any Sugestion?
Thanks


Title: Re: Help with picaxe08M
Post by: luiz_a2software on November 12, 2011, 10:09:15 10:09
try while

i = 0
while i < 3000
   pause 1
   i = i + 1
wend