Shop OBEX P1 Docs P2 Docs Learn Events
creating an array — Parallax Forums

creating an array

kalvinkalvin Posts: 4
edited 2009-05-12 02:09 in Propeller 1
ok, so with some tinkering and looking into the manual i am found as clueless as i started. I'm creating a robot that has an ir range finder attached to the servo·so that i can scan the area and look for obsticles, goals,etc. Any way i have no idea on how to store the values i get from the range finder into an array. do i have to make seperate variables and turn my servo a certain amount then record the value. Isn't their a smoother way than stop, take value, turn, stop, etc. I'm trying to keep to one cog and minimum memory. Help is appreciated.

Comments

  • CassLanCassLan Posts: 586
    edited 2009-05-12 02:08
    kalvin,
    Go ahead and post what code you've got thus far so folks can make recommendations (using the code "#" button to retain formatting).
    from what you've said though, I would say:

    VAR
    byte array[noparse][[/noparse]500], ctr
    ...
    ...
    repeat ctr from 1 to 499
        array[noparse][[/noparse]ctr-1] := sensorvalue
    

    This is a way that arrays can be defined and used in spin.

    Rick
  • SRLMSRLM Posts: 5,045
    edited 2009-05-12 02:09
Sign In or Register to comment.