pwm to pin using variable


Closed Thread
Results 1 to 4 of 4
  1. #1
    wsmrite's Avatar
    wsmrite Guest

    Default pwm to pin using variable

    I want to send a PWM output to a pin that is chosen at random. How do I specify the PIN in the PWM syntax using a variable generated by RANDOM?

    I.E. I would normaly send:

    PWM PORTD.0, 155,50

    Want to send:

    PWM "random pin",155,50

    Where "random pin" would be a variable generated by a previous RANDOM command being a number between 0 and 7 corresponding to the pin number on port D. I know how to generate the random number I need to know how to use a variable for the pin in the PWM command.

  2. #2


    Did you find this post helpful? Yes | No

    Red face use an array?

    You could define an array, then have your random # be the array element pointer (after defining each element).

    ------------Picster--------------

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    too do this easy you'll be limited to the available pin number stated in section 4.11 in the PBP manual.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,615


    Did you find this post helpful? Yes | No

    Wink With a little brain work ...

    Hi, writer

    Manual section 5.61 ... you just have to format your random number to meet section 4.11

    Rather Easy ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Is this a K Type sensor?
    By jessey in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 21st November 2009, 13:55
  2. Variable PWM PIC18F2431
    By trr1985 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 12th June 2009, 06:03
  3. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17:07

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts