Shop OBEX P1 Docs P2 Docs Learn Events
Please help- random data selection — Parallax Forums

Please help- random data selection

geo2012geo2012 Posts: 3
edited 2009-11-28 03:56 in BASIC Stamp
I would be greatful if someone can help me figure out random data selection. I am trying to get my bs2px to randomly select the data below when a button I have interfaced is pressed.



here is an example:
lower8··· VAR··· OUTL

info······· VAR··· Byte

digit 1··· DATA· %00000001, ( 7 more bytes)
digit 2··· DATA· %00000010
digit3···· DATA· %00000100
digit4·····DATA· %00001000
digit5·····DATA· %00010000
digit6··· DATA···%00100000

main:
random
here I want it to randomly select·a digit·stored·in·data every time a button I have interfaced is pressed
I can get it to read it with
FOR info = 0 TO 7
READ (digit1 + info), lower8
but not randomly read it

Thank You

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2009-11-28 03:56
    EPROM 'DATA' is filled from location 0 up.

    So, all you have to do is use the "RANDOM" statement to create a random value from 0 to 7, and then issue a READ statement with that value.
Sign In or Register to comment.