Is there A better way to program this.
Jeff2
Posts: 46
What I need help with is,
If Pin[noparse][[/noparse]23] is pushed fast (toggled, on and off)= it run's the program = (right)
But if Pin[noparse][[/noparse]23] is held at the end of the (right) program, all the led's light up and stay lit till you let go of pin[noparse][[/noparse]23].
What I need to know is, this. Is there A way to program it so when you push (toggled, on and off) pin[noparse][[/noparse]23] it will only run the (right) program.
If you hold down the pin[noparse][[/noparse]23] it will only turn on all led's, till you let go of the pin. Then all led's will be off.
Pin[noparse][[/noparse]23] is off = no led's are on
Pin[noparse][[/noparse]23] pushed = (right)
Pin[noparse][[/noparse]23] held down = all led's on till you let go of Pin[noparse][[/noparse]23]
I hope you get what I am trying to say....
If Pin[noparse][[/noparse]23] is pushed fast (toggled, on and off)= it run's the program = (right)
But if Pin[noparse][[/noparse]23] is held at the end of the (right) program, all the led's light up and stay lit till you let go of pin[noparse][[/noparse]23].
What I need to know is, this. Is there A way to program it so when you push (toggled, on and off) pin[noparse][[/noparse]23] it will only run the (right) program.
If you hold down the pin[noparse][[/noparse]23] it will only turn on all led's, till you let go of the pin. Then all led's will be off.
Pin[noparse][[/noparse]23] is off = no led's are on
Pin[noparse][[/noparse]23] pushed = (right)
Pin[noparse][[/noparse]23] held down = all led's on till you let go of Pin[noparse][[/noparse]23]
I hope you get what I am trying to say....
con _clkmode = xtal1 + pll16x _xinfreq = 0_500_000 pub Kid repeat if ina [noparse][[/noparse]23] == 1 right pub right dira[noparse][[/noparse]0..19] := %11111111111111111111 outa[noparse][[/noparse]0..19] := %00000000000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000000000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %10000000000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11000000000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11100000000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11110000000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111000000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111100000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111110000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111000000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111100000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111110000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111000000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111100000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111110000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111111000000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111111100000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111111110000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111111111000 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111111111100 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111111111110 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %11111111111111111111 REPEAT WHILE ina[noparse][[/noparse]23] == 1 dira[noparse][[/noparse]0..19] := %11111111111111111111 outa[noparse][[/noparse]0..19] := %11111111111111111111 waitcnt(clkfreq/4 + cnt) outa[noparse][[/noparse]0..19] := %00000000000000000000
Comments
Post Edited (Mike G) : 5/21/2010 12:43:11 AM GMT
After running right just keep all the outputs high until input 23 is no longer high.
..steve
When the pin[noparse][[/noparse]23] is pushed it run's
the (right) program.
If pin[noparse][[/noparse]23] is held it run's the right
program, then it run's all led's till
you let go of the pin.
What I want is. If pin[noparse][[/noparse]23] is held it will
skip (right) program and just go to
all led's on till pin is let go.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
JonnyMac I have the Propeller Rapid Prototyping Module, I have led's P0 to P19 are the led's and pin[noparse][[/noparse]23] for the input. So I guess I don't know how your program work's to change it to make it work on mine..... I wish I did.............Some day
All joking aside, you really want to avoid using "magic numbers" for IO pins in your listing; it's absolute bollucks.· Yeah, yeah, I know some Parallax manuals show code this way but those writing such manuals teach programming, they don't put it into embedded products for sale.· I do.· Trust me, when you're trying to redesign a PCB and the connections change the last thing you want to do is go through your code doing line-by-line changes of IO pin #s.· And, no, you can't use global replace because numbers could be valid elsewhere.
Of course, not having your hardware I can't test the attached code, but given the amount of programming I do I suspect it will work fine.·
Sorry if I sound harsh; you asked for "better" and then rejected it out-of-hand.· Even if you're not doing programming that goes into products for sale like I do, you want to develop good coding habits so that you can spend more time enjoying your programs than chasing self-induced bugs inside them.· Yes, I'm speaking from experience.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
Post Edited (JonnyMac) : 5/21/2010 2:17:57 AM GMT
and time.