Nee help with a code?
I am new here and a beginer. I'm trying to write a code that Random choses a output between two pins for 2 seconds, then returns back Low.·I think i have part figured out, just not the random part.
·Thanks for any help
············ motor:· ·' my Sub
·············· Random· ?????????????·· 'I want pin 6 or 7 to high for 2 seconds and return low
························ Pause 2000
·························· low 6
·························· low 7
···················· Return
·Thanks for any help

············ motor:· ·' my Sub
·············· Random· ?????????????·· 'I want pin 6 or 7 to high for 2 seconds and return low
························ Pause 2000
·························· low 6
·························· low 7
···················· Return
Comments
result VAR WordMain: result = 3 ' set initial "seed" value RANDOM result ' generate random number DEBUG DEC ? result ' show the result on screen GOTO Main
then just assign a pin to go low if the number matches the result.
Post Edited (kf4ixm) : 1/14/2010 4:14:22 PM GMT
i have pins 6 & 7 at LOW.
i want to make a call (gosub motor) and have the call RANDOM chose pin 6 or 7 and go HIGH 5v output for 2 seconds and return back LOW, and return from my call.
Post Edited (kf4ixm) : 1/15/2010 12:06:33 AM GMT
···· motor:· ·' my Sub
·············· Random··· 'I want pin 6 or 7 to high for 2 seconds and return low
··················
···························High 6
···························High 7
······························· pause 2000
································ LOW 6
································ LOW 7
···················· Return
' {$STAMP BS2} ' -----[noparse][[/noparse] I/O Definitions ]------------------------------------------------- 1 PIN 6 'assigns the name of 1 to pin 6 2 PIN 7 'assigns the name of 2 to pin 7 result VAR word main: result = 2 RANDOM result HIGH result PAUSE 2000 LOW result GOTO main
this should get you close.
Post Edited (kf4ixm) : 1/15/2010 1:41:18 AM GMT
I'm new to the basic stamp and pbasic. I love tinkering with electronics and am planning to get more serious. i've taking C++ for a while and enjoyed it.
Again THANKS