question about seemingly random control of solenoids with Basic I
A student of mine would like to control 13 solenoids in a seemingly random pattern with a basic stamp.· Is it possible to use "random" syntax to·select··I/O pins to control?
Comments
If value is a randomized WORD value, the outputs will cycle pseudo-randomly.
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
Personal Links with plenty of BASIC Stamp info
StampPlot - Graphical Data Acquisition and Control
AppBee - XBee ZigBee / IEEE 802.15.4 Adapters & Devices
seed would be a word variable that you'd initialize to some value at the beginning of your program. The assignment statement has two parts. One (OUTS & $E000) extracts the current output settings for pins 13-15. This way, they are not affected by changing the whole output register. The other (seed // $2000) does a modulo operation that takes the current value of seed and produces a 13 bit remainder, a value from 0-$1FFF that's effectively random. Each time you execute these two statements, you'd change the pattern of outputs for pins 0-12 in a pseudo-random way. It's pseudo-random in that the values are reproducible given the initial seed value, but the numeric properties of the sequence of values is effectively random.