Forum Update - Announcement about May 10th, 2018 update and your password.

Must I specify SPI pins as hardwired pins numbers?

When I use a shift out operator, can I not use a variable to specify the pin number?

If not, why not? I always thought that naming pin numbers is good programming practice.
Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
Cool, CA, USA 95614

Comments

  • 4 Comments sorted by Date Added Votes
  • jmgjmg Posts: 11,425
    When I use a shift out operator, can I not use a variable to specify the pin number?

    If not, why not? I always thought that naming pin numbers is good programming practice.

    Depends what you mean.
    In any language, it is usual/desirable to have a common defined name, that is used many times elsewhere in code.

    Mostly, those are actually constants, in that the compilers evaluate and replace at compile time.

    A true variable, allows a run time change, and that is slower, and requires more code.
  • JonnyMacJonnyMac Posts: 6,009
    edited March 4 Vote Up0Vote Down
    If not, why not? I always thought that naming pin numbers is good programming practice.
    It is. I have also asked the Blockly team to considered named CONSTANTS for pin numbers, because in a given application most don't change.
    Jon McPhalen
    Hollywood, CA
    It's Jon or JonnyMac -- please do not call me Jonny.
  • I meant specifically in Blockly.
    Re-inventing the wheel is not a waste of time if, when you are done, you understand why it is round.
    Cool, CA, USA 95614
  • Ken GraceyKen Gracey Posts: 6,210
    edited March 5 Vote Up0Vote Down
    Tom, for some blocks (pulses, servos, audio) you can choose the "other" pin number and insert a variable.

    We are making two improvements to this system for the next release. All blocks appropriate for this addition will have the "other" option and we will also implement the constant definition so it does not use RAM.

    So, it's coming!

    Ken Gracey
Sign In or Register to comment.