Shop OBEX P1 Docs P2 Docs Learn Events
i need help in this!!!!!!! — Parallax Forums

i need help in this!!!!!!!

ardilloardillo Posts: 4
edited 2007-08-08 10:20 in Propeller 1
hi!!!! i have problems with this program:
*** when method init_standby called method armed, an then i try to exit armed i have to strike input 1 twice or maintain pushed for about .5 secs,output 7 gives a little 2 pulses(dont want it!!!). i·supposed to only·need one pulse for exit armed

*** i want that init_standby do not execute if input 3 == 1.execute if input 3 == 0
i try to add another pub but it dos'nt work
····

········ HHHHHHHEeeeEEEEEELLLLLLLPPPPPPPPPP!!!!!!!




var
· long stack [noparse][[/noparse]12]···· 'stack space for cognew instruction
· Pub init_standby |· Lock
{{
pin 0 = activation
pin 1 =· deactivation
pin 2 = monitors the status of sensors
pin 3 =·machine is on·}}
· dira [noparse][[/noparse]0..2]~· 'sets pin 0-2 as inputs



· repeat··································· 'loops for always cheking below lines
··· Lock· := ina[noparse][[/noparse]0]·················· 'takes the value of input pin 0
··· if· Lock == 1···················· 'condition for the calling of armed sub routine
····· cognew (flasher,@ stack)· 'a new cog executes sub_routine
····· armed································· 'sub_routine
····· if armed == 1
······· cogstop (1)
pub armed | Unlock,Lock············ 'sub_routine armed

· dira [noparse][[/noparse]6..8]~~······················ 'sets pin 16-18 as output
· !outa [noparse][[/noparse]7]··························· 'raise pulse for locked doors
· waitcnt(6_000_000 + cnt)
· !outa [noparse][[/noparse]7]····················· 'the drop pulse for locked
· repeat
··· !outa [noparse][[/noparse]6]
··· repeat
······ Unlock· := ina [noparse][[/noparse]1]
····· if· Unlock· == 1
······· !outa [noparse][[/noparse]7]
······· return 1
pub flasher : index· | pin· ' {declaration of the the sub_routine led_Flasher
······························· 'returning its value trought "index"}.{"Pin" is a local variable.}···············································································································································································································································
· dira [noparse][[/noparse]16..23]~~
··· repeat {1}··················· 'Endlessly loop···············································································································································

{repeat {2} is used to turns leds on from left to right}
····· repeat{2} index from 1 to 7 'will execute until "index" reach 7, when exit repeat {2} automaticlly "index" return to 0
······· pin := index + 16········ 'indicates which led in the corresponding demo_board pin turns on
······· !outa [noparse][[/noparse]pin]·············· 'toggles pin output
······· waitcnt(2_500_000 + cnt)· 'delay time
······· !outa [noparse][[/noparse]pin]·············· 'toggles pin output again
{repeat {3} is used to turns leds on from right to left}
····· repeat{3} index from 1 to 7 'as "index" loose its value from repeat {2},will execute until "index" reach 7
······· pin := 23 - index········ 'indicates which led in the corresponding demo_board pin turns on
······· !outa [noparse][[/noparse]pin]············· 'toggles pin output
······· waitcnt(2_500_000 + cnt)· 'delay time
······· !outa [noparse][[/noparse]pin]·············· 'toggles pin output again
······

Comments

  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-08-08 08:08
    can you attach it in a file, the indentation has been changed I think

    Graham
  • KaioKaio Posts: 253
    edited 2007-08-08 09:49
    ardillo,

    you are calling the subroutine armed twice. One time without checking result and one in the if statement. You should it only call in the if statement.

    Thomas
  • Graham StablerGraham Stabler Posts: 2,507
    edited 2007-08-08 10:20
    well spotted you can just have

    armed
    cogstop(1)

    because armed will never return unless the button is pressed.
Sign In or Register to comment.